I am looking for a task which could download a latest commit based on the tag from Azure Repos. I mean whole files/folders structures from Azure Repos which is than use to build the application. Then use it for different environments', like Test, than Integration, and Production. Now, I am a bit confused with the order/tasks/reusability:
DownloadGitHubRelease@0
and PublishPipelineArtifact@1
to publish that artifact? By the way I do not see the task which could download packages from Azure Repo, only that one DownloadGitHubRelease@0
which is designed for GitHub, am I right?DownloadBuildArtifacts@1
(means above package), and extract it with ExtractFiles@1
.Is that correct way? Or is that any better approach? My beginning:
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'
My imagination is that developer commit new package with tag, than Azure Devops takes the changes and run pipeline.
Based on comment and question description, the pipeline need to listen the commit tag changes in Automotive repo, then trigger pipeline and download azure repo based on related changed tag.
To meet your requirement, you can set tag trigger in repo resources and directly use - checkout: repoalias
to download the azure repo based on related changed tag.
Tag trigger:
resources:
repositories:
- repository: Automotive
type: git
name: autoomotive
ref: master
trigger:
tags:
include:
- '*'
Download Azure Repo:
- checkout: Automotive
Here is an example:
trigger:
branches:
include:
- master/*
resources:
repositories:
- repository: pipeline
type: git
name: pipeline
ref: auto/*
- repository: Automotive
type: git
name: autoomotive
ref: master
trigger:
tags:
include:
- '*'
variables:
- template: variables.yml
stages:
- stage: Build
jobs:
- job: DownloadPackage
pool:
vmImage: 'ubuntu-latest'
steps:
- checkout: Automotive
- 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'
When developers commit new package with tag to azure repo, it will automatically trigger the pipeline and the checkout step will download the azure repo with the related committed tag.
If you need to download the repo which is used to create pipeline, you can add - checkout: self to check the related repo.
Here is the doc about checkout definition.
Result: