是否可以使用变量为 azure devops 模板配置远程存储库?
resources:
repositories:
- repository: pipelines
type: githubenterprise
name: my-company/pipelines
endpoint: my-endpoint
ref: refs/heads/my-branch
不幸的是,以下代码无法通过始终选择远程存储库中的默认分支来工作。
variables:
- name: PARENT_PIPELINES_GIT_REFERENCE
value: refs/heads/my-branch
resources:
repositories:
- repository: pipelines
type: githubenterprise
name: my-company/pipelines
endpoint: my-endpoint
ref: ${{ variables.PARENT_PIPELINES_GIT_REFERENCE }}
如果您想使用用户定义的管道变量指定存储库资源上“
ref
”键的值,可以使用宏语法($(var)
)来传递该值。
variables:
- name: PARENT_PIPELINES_GIT_REFERENCE
value: my-branch
resources:
repositories:
- repository: pipelines
type: githubenterprise
name: my-company/pipelines
endpoint: my-endpoint
ref: $(PARENT_PIPELINES_GIT_REFERENCE)