Azure devops 如何在作业中下载*所有*管道资源?
Azure devops 如何在作业中下载*所有*管道资源?,azure-devops,azure-pipelines,Azure Devops,Azure Pipelines,部署作业自动下载所有管道资源。但是,标准的作业没有。我尝试使用-download:current,但这并没有下载管道资源 我想这样做的原因是为了模拟GitOps的部署。模拟将包括一个步骤,该步骤执行显示差异的git diff,以供审查 但是,我在中没有看到all或*选项 我目前的解决方法是在真正的部署之前先对“Temp”环境进行部署 更新: 这是我尝试过的一个例子 resources: pipelines: - pipeline: auth project: myproj
部署
作业自动下载所有管道资源。但是,标准的作业
没有。我尝试使用-download:current
,但这并没有下载管道资源
我想这样做的原因是为了模拟GitOps的部署。模拟将包括一个步骤,该步骤执行显示差异的git diff,以供审查
但是,我在中没有看到all
或*
选项
我目前的解决方法是在真正的部署之前先对“Temp”环境进行部署
更新:
这是我尝试过的一个例子
resources:
pipelines:
- pipeline: auth
project: myproj
source: auth CI
trigger:
branches:
include:
- master
...
jobs:
- job: diagnostics
displayName: Job Diagnostics
steps:
- checkout: self
# - download:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
path: $(Build.SourcesDirectory)
- bash: |
env | sort
displayName: Display environment variables
- bash: |
pwd
displayName: Present working directory
- bash: |
find $(Pipeline.Workspace) -type f -print
displayName: Display files
更新:
我正在考虑的另一种方法是创建一个管道来创建另一个管道。这样,管道资源列表不需要是Azure管道YAML,它可以是CSV或简化的YAML,在这种情况下,我可以生成它
resources:
pipelines:
- pipeline: pipelineAlias1
project: myproj
source: auth CI
branch: master
trigger:
branches:
include:
- master
- pipeline: pipelineAlias2
project: myproj
source: auth CI
branch: master
trigger:
branches:
include:
- master
...
job:
steps:
- download: pipelineAlias1
- download: pipelineAlias2
然后将其设置为另一个Azure管道,以便在更新时执行
如何在作业中下载所有管道资源
事实上,这是关于使用download关键字下载管道工件的已知问题
您可以从以下票证跟踪此问题:
要解决此问题,请尝试使用任务而不是下载关键字:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
path: $(Build.SourcesDirectory)
更新:
我注意到您的yml文件,似乎您没有在管道中添加构建作业。该任务用于:
从该管道的早期阶段下载管道工件,
或者从另一条管道
因此,我们需要添加stage来构建管道以生成工件,否则,不会下载任何管道工件
检查我的测试YAML文件:
variables:
ArtifactName: drop
stages:
- stage: Build
jobs:
- job: Build
displayName: Build
pool:
name: MyPrivateAgent
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)\LibmanTest'
targetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: LibmanTest'
inputs:
ArtifactName: $(ArtifactName)
- stage: Dev
dependsOn: Build
jobs:
- job: Dev
displayName: Dev
pool:
name: MyPrivateAgent
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)\TestSample'
targetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: TestSample'
inputs:
ArtifactName: $(ArtifactName)
- stage: Deployment
dependsOn: Dev
pool:
name: MyPrivateAgent
jobs:
- deployment: Deployment
displayName: DeployA
environment: 7-1-0
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
path: $(Build.SourcesDirectory)
如您所见,我使用两个阶段Build
和Dev
将项目LibmanTest
和TestSample
复制为工件,然后使用任务DownloadPipelineArtifact下载这两个工件
测试结果:
更新2:
您的示例仍然没有显示resources.pripelines
因此,现在您要从其他管道下载工件,不需要使用任务DownloadPipelineArtifact的默认配置:
resources:
pipelines:
- pipeline: xxx
project: MyTestProject
source: xxx
trigger:
branches:
include:
- master
jobs:
- deployment: Deployment
displayName: DeployA
environment: 7-1-0
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact For Test'
inputs:
buildType: specific
project: MyTestProject
definition: 13
测试结果:
此外,您可以从classic editor检查配置,然后获取YAML文件:
variables:
ArtifactName: drop
stages:
- stage: Build
jobs:
- job: Build
displayName: Build
pool:
name: MyPrivateAgent
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)\LibmanTest'
targetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: LibmanTest'
inputs:
ArtifactName: $(ArtifactName)
- stage: Dev
dependsOn: Build
jobs:
- job: Dev
displayName: Dev
pool:
name: MyPrivateAgent
steps:
- task: CopyFiles@2
displayName: 'Copy Files to: $(build.artifactstagingdirectory)'
inputs:
SourceFolder: '$(System.DefaultWorkingDirectory)\TestSample'
targetFolder: '$(build.artifactstagingdirectory)'
- task: PublishBuildArtifacts@1
displayName: 'Publish Artifact: TestSample'
inputs:
ArtifactName: $(ArtifactName)
- stage: Deployment
dependsOn: Dev
pool:
name: MyPrivateAgent
jobs:
- deployment: Deployment
displayName: DeployA
environment: 7-1-0
strategy:
runOnce:
deploy:
steps:
- task: DownloadPipelineArtifact@2
displayName: 'Download Pipeline Artifact'
inputs:
path: $(Build.SourcesDirectory)
希望如此。这行不通。未发现任何管道瑕疵downloaded@ArchimedesTrajano,作为我这边的测试,它工作正常,请检查我的更新答案和详细信息,您能检查一下它是否对您有帮助吗?您好,您的示例仍然没有显示资源。pripelines
@ArchimedesTrajano,您说过您使用-download:current
,所以我从当前管道下载它,但是现在您想要从其他管道下载工件。因此,您需要配置task DownloadPipelineArtifact,而不是使用默认值。我将用一个详细的样本更新我的答案。@ArchimedesTrajano,再次更新答案,请检查它是否解决了您的问题。