2

在我的 Flutter 移动应用项目中,我有来自 GitLab 的私有依赖项。它在pubspec.yamlgit 存储库链接中指定,pub get如果我使用 ssh 可以成功运行(我已生成 ssh 密钥并将其添加到我的 gitlab 帐户)

  my_private_package:
    git:
      url: ssh://git@************/my_private_package.git

现在我想用 AppCenter 构建我的应用程序并部署到商店。在 AppCenter 构建阶段无法使用 ssh 密钥,因此我看到的唯一可行的解​​决方案是使用GitLab Deploy Token作为环境变量从 AppCenter 机器访问我的私有包。访问存储库的 Git 链接变为:

  my_private_package:
    git:
      url: https://gitlab+deploy-token-1:${DEPLOY_TOKEN}@************/my_private_package.git

现在,据我了解, pubspec 无法DEPLOY_TOKEN以这种方式解析环境变量。pub get完成错误:

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   

我还尝试使用上面错误消息中提到的个人访问令牌,但得到相同的结果。尽管如果指定了环境变量,则git clone https://gitlab+deploy-token-1:${DEPLOY_TOKEN}@*******/my_private_package.git从命令行可以正常工作。DEPLOY_TOKEN

我的问题:是否可以直接使用环境变量pubspec.yaml?如果不是,我如何从另一台(不是 gitlab 运行器)CI 机器获取我的私有包?

4

0 回答 0