Reputation: 57
i'm trying to create a build pipeline for my flutter app using azure devops.
I use the azure extension for flutter from Aloïs Deniel. The flutter install task passes successfully. The Flutter build hangs and throws the following error in an infinite loop:
stderr: Cloning into bare repository '/Users/runner/hostedtoolcache/Flutter/1.26.0-1.0.pre-dev/macos/flutter/.pub-cache/git/cache/app_alh_packages-384b2d81da8d887d80ab6f47deedece96035bf0c'...
fatal: could not read Username for 'https://jointhedartsidewehavewidgets.visualstudio.com': terminal prompts disabled
exit code: 128
pub get failed (server unavailable) -- attempting retry 1 in 1 second...
My azure pipeline.yaml file is quite simple:
variables:
projectDirectory: 'cleanedBloc'
trigger:
- main
pool:
vmImage: 'macos-latest'
steps:
- task: FlutterInstall@0
inputs:
channel: 'dev'
version: 'latest'
- task: FlutterBuild@0
inputs:
target: 'ios'
projectDirectory: $(projectDirectory)
I am happy to receive help. Thanks in advance.
Upvotes: 2
Views: 3930
Reputation: 30333
It looks like the flutter build task was trying to download a azure git dependency from https://jointhedartsidewehavewidgets.visualstudio.com
. Since the cloud build agent doesnot have the credentials for this git repo. It would throw out above error.
You can check about below workarounds to fix this issue.
1, Add the git repo credentials in git url which is defined in your pubspec.yaml file. See below:
name: FlutterProject
environment:
sdk: ">=2.0.0 <3.0.0"
dependencies:
flutter:
sdk: flutter
cupertino_icons: 0.1.2
Yourpackage:
git:
url: https://user_name:[email protected]/yourProject/_git/yourRepo
ref: master
Or you can use Personal access token with Code read scope
for the credential.
Yourpackage:
git:
url: https://{Personal Access Token}@jointhedartsidewehavewidgets.visualstudio.com/yourProject/_git/yourRepo
ref: master
If you didnot want to expose your Personal Access token in the pubspec.yaml file. You can create a pipeline secret variable to hold the PAT. And add a replace token task to add the PAT to the pubspec.yaml file.
See below example: Change your pubspec.yaml as below:
Yourpackage:
git:
url: https://#{token}#@jointhedartsidewehavewidgets.visualstudio.com/yourProject/_git/yourRepo
ref: master
Define a secret variable in your pipeline.
Add replace token task to replace the #{token}#
with the PAT.
- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in pubspec.yaml'
inputs:
targetFiles: pubspec.yaml
- task: FlutterInstall@0
Upvotes: 2