在 Azure 管道的另一个作业中使用从先前作业签出的文件

互联网 更新时间:2023-04-26 21:08:02

Leo*_*SFT 6

在 Azure 管道的另一个作业中使用从先前作业签出的文件

如果您使用的是自托管代理默认情况下,不会在两个连续作业之间清理任何工作区。因此,您可以进行增量构建和部署,前提是实施任务以利用它。

因此,我们可以- checkout: none在下一个作业中使用跳过在 Build 作业中签出相同的代码:

- job: Test
  displayName: Run Unit and Cypress Tests
  dependsOn: Build
  steps:
    - checkout: none
    - template: templates/angularlinttest.yml

但正如 Bo Søb Petersen 所说,DependsOn 并不能确保使用相同的代理。您需要向该特定构建代理添加用户功能,然后在构建定义中将该功能作为需求:

  pool:
    name: string
    demands: string | [ string ]

请查看此文档如何将 TFS 构建发送到特定代理或服务器以获取更多信息。

在测试作业中,我们可以使用预定义的变量$(System.DefaultWorkingDirectory)来访问 Node 和 npm 的文件。

另一方面,如果您使用的是托管代理,我们需要使用PublishBuildArtifacts任务将 Artifact 发布到 azure 工件,以便我们可以DownloadBuildArtifacts在下一个作业中使用任务下载工件:

jobs:
- job: Build
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
  - script: npm test
  - task: PublishBuildArtifacts@1
    inputs:
      pathtoPublish: '$(System.DefaultWorkingDirectory)'
      artifactName: WebSite

# download the artifact and deploy it only if the build job sueeded
- job: Deploy
  pool:
    vmImage: 'ubuntu-16.04'
  steps:
  - checkout: none #skip checking out the default repository resource
  - task: DownloadBuildArtifacts@0
    displayName: 'Download Build Artifacts'
    inputs:
      artifactName: WebSite
      downloadPath: $(System.DefaultWorkingDirectory) 

您可以查看官方文档和示例以获取更多详细信息。

更多推荐

作业,从先,管道,文件,Azure

本文发布于:2023-04-26 21:08:01,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/hyzx/8d44e36e4a0f93099cff7452dce401b1.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   从先   管道   文件   Azure

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!

  • 89746文章数
  • 23117阅读数
  • 0评论数