gpt4 book ai didi

azure - 使用 azure devops 进行 flutter 构建管道

转载 作者:行者123 更新时间:2023-12-02 23:39:00 24 4
gpt4 key购买 nike

我正在尝试使用 azure devops 为我的 flutter 应用程序创建构建管道。

我使用 Aloïs Deniel 的 azure 扩展来实现 flutter。flutter 安装任务成功通过。Flutter 构建挂起并在无限循环中抛出以下错误:

 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...

我的 azure pipeline.yaml 文件非常简单:

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)

我很高兴得到帮助。提前致谢。

最佳答案

看起来 flutter 构建任务正在尝试从 https://jointhedartsidewehavewidgets.visualstudio.com 下载 azure git 依赖项。由于云构建代理没有此 git 存储库的凭据。它会抛出上述错误。

您可以检查以下解决方法来解决此问题。

1,在 pubspec.yaml 文件中定义的 git url 中添加 git repo 凭据。见下文:

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:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="3b4b5a48484c54495f7b515452554f535e5f5a494f48525f5e4c5e535a4d5e4c525f5c5e4f48154d52484e5a57484f4e5f525415585456" rel="noreferrer noopener nofollow">[email protected]</a>/yourProject/_git/yourRepo
ref: master

或者您可以将 Personal access token代码读取范围一起使用作为凭据。

Yourpackage:
git:
url: https://{Personal Access Token}@jointhedartsidewehavewidgets.visualstudio.com/yourProject/_git/yourRepo
ref: master

如果您不想在 pubspec.yaml 文件中公开您的个人访问 token 。您可以创建一个管道 secret 变量来保存 PAT。并添加替换 token 任务以将 PAT 添加到 pubspec.yaml 文件中。

参见下面的示例:如下更改您的 pubspec.yaml:

 Yourpackage:
git:
url: https://#{token}#@jointhedartsidewehavewidgets.visualstudio.com/yourProject/_git/yourRepo
ref: master

在管道中定义 secret variable

enter image description here

添加 replace token task 以将 #{token}# 替换为 PAT。

- task: qetza.replacetokens.replacetokens-task.replacetokens@3
displayName: 'Replace tokens in pubspec.yaml'
inputs:
targetFiles: pubspec.yaml

- task: FlutterInstall@0

关于azure - 使用 azure devops 进行 flutter 构建管道,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65630516/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com