yml 管道:使用来自多个存储库的代码发布工件
yml pipeline: publish artifact with code from multiple repositories
我正在尝试从多个存储库构建代码并将其发布为单个构建工件。
当我签出另一个存储库时,它会清除 ArtifactStagingDirectory。
有没有办法在作业之间保存代码?
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'
作为一个简单的答案,否。但是,如果您想“玩”工件,您可以下载以前代理的构建结果 运行。例如:
第 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
第 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
构建结果:
我正在尝试从多个存储库构建代码并将其发布为单个构建工件。
当我签出另一个存储库时,它会清除 ArtifactStagingDirectory。
有没有办法在作业之间保存代码?
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'
作为一个简单的答案,否。但是,如果您想“玩”工件,您可以下载以前代理的构建结果 运行。例如:
第 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
第 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
构建结果: