gpt4 book ai didi

azure-pipelines - 在 Azure 管道作业之间共享文件

转载 作者:行者123 更新时间:2023-12-04 04:29:45 25 4
gpt4 key购买 nike

在 Azure 管道的文档中,我读到:

Each agent can run only one job at a time. To run multiple jobs in parallel you must configure multiple agents.

When you run a pipeline on a self-hosted agent, by default, none of the sub-directories are cleaned in between two consecutive runs. As a result, you can do incremental builds and deployments, provided that tasks are implemented to make use of that. You can override this behavior using the workspace setting on the job.

Pipeline artifacts provide a way to share files between stages in a pipeline or between different pipelines. They are typically the output of a build process that needs to be consumed by another job or be deployed.



作为初学者,看完这篇,我有一些疑惑:
  • 如果我在 azure-pipelines.yaml 中有 2 个作业(第 2 个作业在第 1 个之后运行),这两个作业会在同一个代理中运行吗?在同一管道中执行不同的作业共享可通过变量 Pipeline.Workspace 引用的同一工作区? (很明显,在并行作业运行的情况下,它需要多个代理)。
  • 第一项工作一步生成一些文件。是否可以在不使用工件的情况下在第二个作业中使用这些文件(通常使用工件,第一个作业发布工件,第二个作业下载它)?

  • 可以请一些人帮我清除这些疑虑吗?

    最佳答案

    If I have 2 jobs (2nd job runs after the 1st) in an azure-pipelines.yaml, will both the jobs run in the same agent?



    严格来说,不,两者都不是 UI也不是 YAML可以做到这一点。

    正如您从文档中看到的:每个代理一次只能运行一项作业。我们的设计逻辑是,理论上,一项工作是 独立 运行个体,不同作业之间的通信 需要 使用“中间件”,如 variable , artifact等等。

    Do different jobs in the same pipeline share the same workspace that can be referenced via the variable Pipeline.Workspace?



    样本 1:

    我在一个管道中有 2 个工作,一个是 job01另一个是 job02 .

    job01 , 我创建了一个 json 文件到 $(Pipeline.Workspace)姓名 project.json :

    enter image description here

    在job02中,打印路径 $(Pipeline.Workspace)下的文件列表:

    enter image description here

    您可以看到,第二个作业无法访问第一个作业的输出目录。

    但是 ,有一种特殊情况,管道与自代理池一起运行,并且该池中仅存在一个代理。

    此时,它们可以在同一个代理上运行,因为池中只有一个代理。并且,如果您不手动执行 clean作业定义中的操作,在这种特殊情况下,文件可以在作业之间共享,因为它们使用恒定的本地路径。

    样本 2:

    与上一个示例相同,但这次将运行池更改为仅包含 1 个代理的池。

    enter image description here

    The 1st job generates some files in one step. Is it possible to consume those files in 2nd job without using artifacts



    我认为我上面的特殊情况描述和 sample2有回答这个。

    是的,有可能。你可以引用那个来实现这个需求。但是,我们通常建议您使用工件在作业之间传递文件。

    关于azure-pipelines - 在 Azure 管道作业之间共享文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60520650/

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