我正在寻找一个可以根据 Azure Repos 中的标签下载最新提交的任务。我的意思是从 Azure Repos 下载整个文件/文件夹结构,然后用于构建应用程序。然后将其用于不同的环境,例如测试、集成和生产。现在,我对顺序/任务/可重用性有点困惑:
- 第一阶段称为“构建”,可以从 Azure Repo 下载该包,然后发布?所以有两个任务
DownloadGitHubRelease@0
并PublishPipelineArtifact@1
发布该工件?顺便说一句,我没有看到可以从 Azure Repo 下载包的任务,只有DownloadGitHubRelease@0
为 GitHub 设计的任务,对吗? - 第二阶段称为测试,应该使用
DownloadBuildArtifacts@1
(即上述包)下载该工件,然后使用 将其提取出来ExtractFiles@1
。 - 生产阶段的步骤/任务与上述相同。
这是正确的方法吗?或者有更好的方法吗?我的开头是:
trigger:
branches:
include:
- master/*
resources:
repositories:
- repository: pipeline
type: git
name: pipeline
ref: auto/*
- repository: Automotive
type: git
name: autoomotive
ref: master
variables:
- template: variables.yml
- name: releaseTag
value: '18.11.0'
stages:
- stage: Build
jobs:
- job: DownloadPackage
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadGitHubRelease@0
inputs:
repository: 'OEM/Automotive'
tags: |
[latest]
artifactName: 'AutomotivePackage'
downloadPath: '$(System.ArtifactsDirectory)'
- task: PublishPipelineArtifact@1
inputs:
targetPath: '$(System.ArtifactsDirectory)/AutomotivePackage'
artifactName: 'AutomotivePackage'
publishLocation: 'pipeline'
- stage: Test
jobs:
- job: TestDeployment
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'AutomotivePackage'
downloadPath: '$(System.ArtifactsDirectory)'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/AutomotivePackage/*.tar.gz'
destinationFolder: '$(System.DefaultWorkingDirectory)/Automotive'
- stage: Production
jobs:
- job: ProdDeployment
pool:
vmImage: 'ubuntu-latest'
steps:
- task: DownloadPipelineArtifact@2
inputs:
buildType: 'current'
artifactName: 'AutomotivePackage'
downloadPath: '$(System.ArtifactsDirectory)'
- task: ExtractFiles@1
inputs:
archiveFilePatterns: '$(System.ArtifactsDirectory)/AutomotivePackage/*.tar.gz'
destinationFolder: '$(System.DefaultWorkingDirectory)/Automotive'
我的想象是开发人员提交带有标签的新包,然后 Azure Devops 接受更改并运行管道。