I have private dependency from GitLab in my Flutter mobile app project. It is specified in pubspec.yaml
with git repository link and I can successfully run pub get
if I use ssh for it (I have generated ssh key and add it to my gitlab account)
my_private_package:
git:
url: ssh://git@************/my_private_package.git
Now I want to build my app with AppCenter and deploy to stores. It is not possible to use ssh keys on AppCenter build phase, so the only working solution I see is to use GitLab Deploy Token as environment variable to access my private package from AppCenter machine. Git link to access the repository becomes this:
my_private_package:
git:
url: https://gitlab+deploy-token-1:${DEPLOY_TOKEN}@************/my_private_package.git
Now, as far as I understand, pubspec can't resolve DEPLOY_TOKEN
environment variable this way. pub get
completes with error:
Git error. Command: `git clone --mirror https://gitlab+deploy-token-1:******@*******/my_private_package.git /Users/***/Library/flutter/.pub-cache/git/cache/my_private_package***`
stdout:
stderr: Cloning into bare repository '/Users/***/Library/flutter/.pub-cache/git/cache/my_private_package***'...
remote: HTTP Basic: Access denied
remote: You must use a personal access token with 'read_repository' or 'write_repository' scope for Git over HTTP.
remote: You can generate one at https://*****/-/profile/personal_access_tokens
fatal: Authentication failed for 'https://gitlab.*****/my_private_package.git/'
exit code: 128
I also tried to use personal access tokens mentioned in error message above, but getting the same result. Although git clone https://gitlab+deploy-token-1:${DEPLOY_TOKEN}@*******/my_private_package.git
from command line works fine if DEPLOY_TOKEN
environment variable specified.
My question: Is it possible to use evnironment variables directly from pubspec.yaml
? If no, how can I get my private package from another (not gitlab runner) CI machine?
pubspec.yaml
file, or usepath
dependencies with Git repositories that you fetch separately. – Melli