Trying to piece together documentation (https://docs.microsoft.com/en-us/azure/devops/pipelines/process/pipeline-triggers) on trigger/resources to create a set of pipelines that will have a build pipeline triggered by a commit and when that pipeline completes a deployment pipeline consumes the artifacts and deploys them. The reason for having a separate build and deployment pipeline is for batching commits for PRs landing in the mainline (read-as: master)
While the below pipeline files work when a build is manually triggered when a commit is made to the repo both pipelines are started. That isn't what is wanted. If the triggers are removed from the deploy pipeline then the pipeline to pipeline triggers are working.
We want:
- Repo commit
- Build pipeline starts
- Build pipeline publishes artifacts
- Deploy pipeline starts
- Deploy pipeline consumes artifacts
- Deploy pipeline deploys artifacts
build-pipeline.yml
name: $(date:yyyy).$(date:MM).$(date:dd)$(rev:.r)
trigger:
- master
- feature/*
pool:
vmImage: 'ubuntu-latest'
variables:
artifactsName: "artifacts"
steps:
- task: PowerShell@2
inputs:
targetType: 'inline'
script: |
Write-Host "Executing Build"
Write-Host "Creating Artifacts"
New-Item -Type Directory -Path $(artifactsName)
$artifactPath = Join-Path -Path $(artifactsName) -ChildPath "$(Build.BuildNumber).txt"
Set-Content -Path $artifactPath -Value "$(Get-Date)"
pwsh: true
- task: PublishPipelineArtifact@1
inputs:
targetPath: $(artifactsName)
artifactName: buildartifacts
deploy-pipeline.yml
resources:
pipelines:
- pipeline: buildpipeline
source: -splitpipeline-build
trigger:
branches:
include:
- master
- feature/*
pool:
vmImage: 'ubuntu-latest'
steps:
- script: echo Deploy Step
displayName: 'Deploy'