...
1# This step is used to prevent duplication of artifact publishes when there is an issue that would prevent the overall success of the job.
2# Ensuring that we only publish when successful (and two a differently named artifact otherwise) will allow easy retry on a build pipeline
3# without running into the "cannot override artifact" failure when we finally do get a passing run.
4
5# ArtifactName - The name of the artifact in the "successful" case.
6# ArtifactPath - The path we will be publishing.
7# CustomCondition - Used if there is additional logic necessary to prevent attempt of publish.
8
9parameters:
10 ArtifactName: ''
11 ArtifactPath: ''
12 CustomCondition: true
13
14steps:
15 - task: PublishPipelineArtifact@1
16 condition: and(succeeded(), ${{ parameters.CustomCondition }})
17 displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts'
18 inputs:
19 artifactName: '${{ parameters.ArtifactName }}'
20 path: '${{ parameters.ArtifactPath }}'
21
22 - task: PublishPipelineArtifact@1
23 condition: failed()
24 displayName: 'Publish failed ${{ parameters.ArtifactName }} Artifacts'
25 inputs:
26 artifactName: '${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)'
27 path: '${{ parameters.ArtifactPath }}'
View as plain text