gpt4 book ai didi

azure-devops - 如何使用多次 checkout 获取存储库名称

转载 作者:行者123 更新时间:2023-12-05 02:34:35 25 4
gpt4 key购买 nike

管道中是否有任何变量(环境、系统、资源)保存 foo_repo 和 bar_repo 的值?我正在寻找路径(just/code/foo 和 just/code/bar),因为我不想在配置中复制它。

$(Build.Repository.Name) 将返回 self 的 repo 名称,但其他存储库呢?

resources:
repositories:
- repository: foo_repo
type: git
name: just/code/foo
- repository: bar_repo
type: git
name: just/code/bar

stages:
- checkout: foo_repo
- checkout: bar_repo
- checkout: self

最佳答案

When you check out multiple repositories, some details about the self repository are available as variables. When you use multi-repo triggers, some of those variables have information about the triggering repository instead. Details about all of the repositories consumed by the job are available as a template context object called resources.repositories.

For example, to get the ref of a non-self repository, you could write a pipeline like this:

resources:
repositories:
- repository: other
type: git
name: MyProject/OtherTools

variables:
tools.ref: $[ resources.repositories['other'].ref ]

steps:
- checkout: self
- checkout: other
- bash: |
echo "Tools version: $TOOLS_REF"

https://learn.microsoft.com/en-us/azure/devops/pipelines/repos/multi-repo-checkout?view=azure-devops#repository-details

repositories 上下文包含:

resources['repositories']['self'] =
{
"alias": "self",
"id": "<repo guid>",
"type": "Git",
"version": "<commit hash>",
"name": "<repo name>",
"project": "<project guid>",
"defaultBranch": "<default ref of repo, like 'refs/heads/main'>",
"ref": "<current pipeline ref, like 'refs/heads/topic'>",
"versionInfo": {
"author": "<author of tip commit>",
"message": "<commit message of tip commit>"
},
"checkoutOptions": {}
}

关于azure-devops - 如何使用多次 checkout 获取存储库名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70744776/

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