英文:
In Azure resource.pipelines.pipeline, why are both "pipeline" and "source" properties required?
问题
我正在尝试了解Azure管道,但我还不太熟悉。在我们公司的一个管道中,我们有一个属性如下:
resources:
pipelines:
- pipeline: 1234
source: pipeline-name
trigger:
branches:
- master
- refs/heads/master
如果我转到我们的管道页面,我可以看到“pipeline-name”作为一个选项,如果我点击进去,我可以在URL中看到id(1234)。根据我所知,它们是一对一的。
我不确定为什么我需要同时指定pipeline
(id)和source
。提供一个id对我来说有道理,但source
是必需的,而且似乎只有一个“有效的管道名称”才有效。那么为什么两者都是必需的?是否有一种方式可以拥有相同id的2个管道,或者相同管道的2个id?或者这只是一个不太合理的奇怪要求?
有时候,“你尝试了什么以及你期望什么?”这个问题让我感到困扰,但是:我尝试了搜索并期望找到答案。
英文:
I'm trying to learn more about azure pipelines and I'm pretty green. In one of my company's pipelines, we have a property like:
resources:
pipelines:
- pipeline: 1234
source: pipeline-name
trigger:
branches:
- master
- refs/heads/master
If I go to our Pipelines page, I can see "pipeline-name" as an option, and if I click into it, I see the id (1234) in the URL. (Names and ids changed to protect the innocent.) As far as I can tell, they are 1:1.
I am uncertain why I need to specify both pipeline
(id) and source
. Providing an id makes sense to me, but source
is required and only a "valid pipeline name" seems to work. So why are both required? Is there a way to have 2 pipelines with the same id, or 2 ids with the same pipeline? Or is this just a weird requirement that doesn't really make sense?
The "What did you try and what were you expecting?" kills me sometimes, but: I tried googling and expected to find an answer.
答案1
得分: 1
1234
不是管道的 ID。可能有人拿了这个 ID 并放在那里,但您可以将其更改为任何您想要的内容,一切都将正常工作。但如果您更改源,则会更改此资源所引用的管道。
查看文档:
# app-ci YAML 管道
# 我们正在设置一个管道资源,该资源引用了 security-lib-ci
# 管道,并设置管道完成触发器,以便我们的 app-ci
# 管道在 security-lib-ci 管道完成运行时运行
resources:
pipelines:
- pipeline: securitylib # 管道资源的名称。
source: security-lib-ci # 此管道资源引用的管道的名称。
project: FabrikamProject # 仅在源管道位于另一个项目中时需要
trigger: true # 当 security-lib-ci 的任何运行完成时运行 app-ci 管道
steps:
- bash: echo "app-ci 在 security-lib-ci 完成后运行"
> - pipeline: securitylib
指定了管道资源的名称。在管道的其他部分引用管道资源时,请使用此处定义的标签,例如在使用管道资源变量或下载工件时。
> - source: security-lib-ci
指定了此管道资源引用的管道的名称。您可以从 Azure DevOps 门户的多个位置检索管道的名称,例如 Pipelines 登录页面。默认情况下,管道以包含管道的存储库命名。要更新管道的名称,请参阅管道设置。
英文:
1234
is not the id of the pipeline. Maybe someone took the id and put it there but you can change it to anything you want and all will work. But if you change the source you will change the pipeline to which this resource is referring to.
Take a look at the documentation:
# app-ci YAML pipeline
# We are setting up a pipeline resource that references the security-lib-ci
# pipeline and setting up a pipeline completion trigger so that our app-ci
# pipeline runs when a run of the security-lib-ci pipeline completes
resources:
pipelines:
- pipeline: securitylib # Name of the pipeline resource.
source: security-lib-ci # The name of the pipeline referenced by this pipeline resource.
project: FabrikamProject # Required only if the source pipeline is in another project
trigger: true # Run app-ci pipeline when any run of security-lib-ci completes
steps:
- bash: echo "app-ci runs after security-lib-ci comple
> - pipeline: securitylib
specifies the name of the pipeline resource. Use the label defined here when referring to the pipeline resource from other parts of the pipeline, such as when using pipeline resource variables or downloading artifacts.
> - source: security-lib-ci
specifies the name of the pipeline referenced by this pipeline resource. You can retrieve a pipeline's name from the Azure DevOps portal in several places, such as the Pipelines landing page. By default, pipelines are named after the repository that contains the pipeline. To update a pipeline's name, see Pipeline settings.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论