![](/img/trans.png)
[英]Set variable on azure task to pass another task of Azure pipeline
[英]How to reuse DownloadFile from a task in another task Azure Pipeline
我想避免在 Azure DevOps 上的 Pipeline 中重復代碼。 對於一項任務,我需要下載設置,在最后一步,我還需要重用此文件。 我試圖訪問這個變量,但它返回“找不到這個變量”。
stages:
- stage: Setup
jobs:
- job: Verify
steps:
- task: DownloadSecureFile@1
name: mvnSettings
displayName: 'Download maven settings'
inputs:
secureFile: 'settings-azure.xml'
- task: Maven@3
inputs:
mavenPomFile: 'pom.xml'
options: '-s $(mvnSettings.secureFilePath)' ...
- stage: build_and_deploy
jobs:
- job: build_and_deploy
steps:
- task: DownloadSecureFile@1
name: mvnSettings
displayName: 'Download maven settings'
inputs:
secureFile: 'settings-azure.xml'
- task: Maven@3 ...
目標是重用在下面這個塊中創建的變量。
- task: DownloadSecureFile@1
name: mvnSettings
displayName: 'Download maven settings'
inputs:
secureFile: 'settings-azure.xml'
如果你換工作,你就改變了 Build Agent。 這就是您的文件丟失的原因。
您可以使用工件將文件從作業傳遞到作業或從任務傳遞到任務。
您將在此處找到如何操作:
小心點。 有已棄用的構建工件。 改用管道工件
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.