Sync eng/common directory with azure-sdk-tools for PR 1490 (#1905)

* Create a publish-artifact.yml template step within eng/common. This template utilizes PublishPipelineArtifactV1 to upload your artifact only in the case where steps up till the invocation are succeeded(). Otherwise, the artifacts will be uploaded to an alternate artifact name.
This commit is contained in:
Azure SDK Bot 2021-03-15 12:08:13 -07:00 committed by GitHub
parent d7924ce12f
commit 23c1d891b7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -0,0 +1,27 @@
# This step is used to prevent duplication of artifact publishes when there is an issue that would prevent the overall success of the job.
# Ensuring that we only publish when successful (and two a differently named artifact otherwise) will allow easy retry on a build pipeline
# without running into the "cannot override artifact" failure when we finally do get a passing run.
# ArtifactName - The name of the artifact in the "successful" case.
# ArtifactPath - The path we will be publishing.
# CustomCondition - Used if there is additional logic necessary to prevent attempt of publish.
parameters:
ArtifactName: ''
ArtifactPath: ''
CustomCondition: true
steps:
- task: PublishPipelineArtifact@1
condition: and(succeeded(), ${{ parameters.CustomCondition }})
displayName: 'Publish ${{ parameters.ArtifactName }} Artifacts'
inputs:
artifactName: '${{ parameters.ArtifactName }}'
path: '${{ parameters.ArtifactPath }}'
- task: PublishPipelineArtifact@1
condition: failed()
displayName: 'Publish failed ${{ parameters.ArtifactName }} Artifacts'
inputs:
artifactName: '${{ parameters.ArtifactName }}-FailedAttempt$(System.JobAttempt)'
path: '${{ parameters.ArtifactPath }}'