尝试将第二个 github(私有)存储库下载到 azure-devops 的构建管道中。但是有问题。MS“github下载发布”任务似乎有一个与下载标签相关的错误(它成功完成但下载了0个文件等)。一直试图通过 bash、ssh、pat 来完成它,但无法找到一种无需手动输入密码或需要某种干预即可下载任务的方法。
有没有人有关于如何从具有涉及 0 用户交互的特定标签的私人 github 下载的步骤/指南?
如果您的管道是经典 UI 管道。您可以通过运行 git 命令添加要从您的私有 github 下载的脚本任务。请参阅以下步骤:
经典流水线
1,在变量选项卡中创建变量username
和password
(将变量类型更改为密码的秘密)。
如果您的密码或用户名包含@,请将其替换为 %40
2、添加一个powershell任务来运行内联git clone命令:
git config --global advice.detachedHead false
git clone -b mytag --depth 1 https://$(username):$(password)@github.com/mygitaccount/myrepo.git -q
然后你的私有 github 仓库将被下载到文件夹中$(system.defaultworkingdirectory)/myrepo
。
Yaml 管道
如果您使用的是 Yaml 管道。除了上述在脚本任务中运行 git 命令的解决方法外,您还可以使用存储库资源和检出步骤。
首先,您需要创建一个github 服务连接(例如MyPrivateRepoConnection
在下面的示例中)以连接到您的 azure 组织的私有 github 存储库。
然后在 yaml 管道中定义存储库资源和检出步骤。见下面的例子:
resources:
repositories:
- repository: privaterepo
type: github
name: myorg/myrepo
ref: refs/tags/mytag
endpoint: MyPrivateRepoConnection
steps:
- checkout: self #checkout the self source code of this pipeline
- checkout: privaterepo #checkout private repo
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句