I am attempting to build code from multiple repositories and publish it as a single build artifact.
When I checkout another repository it clears the ArtifactStagingDirectory.
Is there a way to save code between jobs?
resources:
repositories:
- repository: A
type: git
name: Engineering/A
ref: master
- repository: B
type: git
name: Engineering/B
ref: pipeline_publish
jobs:
- job: jobA
steps:
- checkout: A
- template: Pipelines/BuildTemplate.yml@A
- template: Pipelines/CopyPluginsTemplate.yml@A
parameters:
destinationFolder: A
- job: jobB
steps:
- checkout: B
- template: Pipelines/BuildTemplate.yml@A
- template: Pipelines/CopyPluginsTemplate.yml@A
parameters:
destinationFolder: B
- job: jobPublishArtifact
dependsOn:
- jobA
- jobB
steps:
- task: PublishBuildArtifacts@1
displayName: Publish Files to be used by the Release build
inputs:
PathtoPublish: '$(Build.BinariesDirectory)'
ArtifactName: 'HMI'
publishLocation: 'Container'
As a simple answer, No. However, if you want to "play" with artifacts, you can download the build results of the previous agent run. As example:
Stage 1:
pool:
name: Azure Pipelines
steps:
- script: 'echo "Write your commands here" >> $(Build.ArtifactStagingDirectory)/fl1.txt'
displayName: 'Command Line Script'
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: drop
Stage 2:
pool:
name: Azure Pipelines
steps:
- script: |
echo "Hello world" >> $(Build.ArtifactStagingDirectory)/fl2.txt
displayName: 'Command Line Script'
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
artifactName: drop
targetPath: '$(Build.ArtifactStagingDirectory)'
- task: PublishPipelineArtifact@1
displayName: 'Publish Pipeline Artifact'
inputs:
targetPath: '$(Build.ArtifactStagingDirectory)'
artifact: drop1
The build results: