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
发布评论