The DependantPipeline (which is triggered by the another pipeline: MainPipeline) causes errors on Azure DevOps:
Download Pipeline artifact
Starting: Download Pipeline artifact
Download from the specified build: #178678
Download artifact to: /agent/_work/64/Pipeline
##[error]Artifact Pipeline was not found for build 178678.
Finishing: Download Pipeline artifact
I tried to trace the file which is responsible to download artifacts in my repo, however by title I cant find it Download Pipeline artifact
. Does it mean someone does not use displayName
parameter and it takes that by default? Or would you give me any hint how to navigate/track files based on the output from Azure DevOps? So far by the the name works for me, not this time.
However, I found those files, which seems to be related with publishing/downloading, I hope:
take_templates.yml
steps:
- task: DownloadPipelineArtifact@2
displayName: "Templates from DEV"
inputs:
artifact: "Pipelines"
buildType: "current"
targetPath: "$(Pipeline.Workspace)/Pipelines"
deployment.yml
parameters:
- name: pipelineOptions
type: object
- name: environment
type: string
jobs:
- deployment: Initializing
displayName: "Initializing"
environment: ${{parameters.environment}}
strategy:
runOnce:
deploy:
steps:
- template: take_templates.yml
- ${{ if eq(parameters.pipelineOptions.isDetectChangesEnabled, 'true') }}:
- template: ./take_changes.yml
take_changes.yml
steps:
- download: current
displayName: "DetectChanges"
artifact: DetectChanges
- task: PowerShell@2
displayName: "Publish Changes"
name: "DetectChanges"
inputs:
targetType: "FilePath"
filePath: take_changes.ps1
arguments: -inputFileName './changes.json'
Currently, I have a pipeline (MainPipeline) which triggers another one (DependantPipeline), which in turns should make a deployment based on the changes, and take (as I believe) uploaded artifacts in the previous pipeline: MainPipeline, to the triggered pipeline: DependantPipeline.
EDIT 1.
I tried different combinations to stick this together based on the articles, however no no no I cant complete this
Dependant pipeline definition:
trigger: none
resources:
repositories:
- repository: Pipelines
type: git
name: Pipelines
ref: test/pipeline
pipelines:
- pipeline: SourcePipeline
project: DEV
source: 'dev-main'
trigger:
branches:
include:
- test/pipeline
# the rest of code goes here
6
When using DownloadPipelineArtifact@2
or download
tasks, the value current
refers to artifacts that were published in the current pipeline, i.e. the same pipeline where these tasks are being used.
Given that your artifacts are coming from MainPipeline
pipeline, you need to use different settings when using these tasks.
Example
Consider the following pipeline
resource that generates an artifact named drop
:
resources:
pipelines:
- pipeline: MainPipeline
project: my-project
source: my-source
trigger: true
You can download the drop
artifact as follows:
steps:
- download: MainPipeline # as defined in the resources section
artifact: drop # as defined in the source pipeline
displayName: Download artifact
# Artifacts from the associated pipeline resource are downloaded to
# $(Pipeline.Workspace)/<pipeline resource identifier>/<artifact name>.
- script: |
ls -la
displayName: List files in artifact directory
workingDirectory: $(Pipeline.Workspace)/MainPipeline/drop
Recommended reading
- Publish and download pipeline artifacts
- DownloadPipelineArtifact@2 – Download Pipeline Artifacts v2 task
- steps.download definition
Based on the update where additional YAML templates were shared, we could see
- The
DownloadPipelineArtifact@2
pipeline task with thedisplayName: "Download Templates from DEV"
intake_templates.yml
was defined to download the artifacts called Pipelines, which should be published during the current build due tobuildType: "current"
, so that it could be consumed; - Another
download
pipeline task with NOdisplayName
property intake_changes.yml
was defined to download the artifacts called DetectChanges, which should be also published during the current build due todownload: current
;
However, neither of the two tasks seemed to incur this error, as the message ##[error]Artifact Pipeline was not found
indicated that it was downloading artifacts called Pipeline, NOT Pipelines or DetectChanges.
For this, I am afraid you will need to check if there was any other DownloadPipelineArtifact@2
or download
task that was defined to consume the artifacts called Pipeline without a displayName
, which should be the one affected.
In addition, we did notice the PublishPipelineArtifact@0
task in init.yml
published the artifacts called Pipelines. Let’s assume init.yml
was from the MainPipeline (dev-main
), and you would expect to download the artifacts Pipelines during the downstream DependentPipeline.
If that was the case, the DependentPipeline should not use DownloadPipelineArtifact@2 buildType: "current"
but use download: SourcePipeline
instead. (SourcePipeline
was the symbolic name of your pipeline resource dev-main
as defined in your Dependent pipeline definition
).
# Dependent pipeline definition
trigger: none
resources:
pipelines:
- pipeline: SourcePipeline
project: DEV
source: 'dev-main'
trigger:
branches:
include:
- test/pipeline
steps:
# - task: DownloadPipelineArtifact@2
# displayName: "Download Templates from DEV"
# inputs:
# artifact: "Pipelines"
# buildType: "current"
# targetPath: "$(Pipeline.Workspace)/Pipelines"
- download: SourcePipeline
artifact: "Pipelines"
displayName: "Download Templates from DEV"
1