JCD*_*ani 2 azure azure-devops azure-pipelines azure-pipelines-yaml
我有模板
dockerbuild.yml
steps:
- task: Bash@3
displayName: Build an image to container registry
inputs:
script : echo $(PATH)
Run Code Online (Sandbox Code Playgroud)
然后是一个变量文件
var.build.yml
- name: PATH
value: 'docker/path'
- name: PATH1
value: 'docker/oldpath'
- name: PATH2
value: 'docker/newpath'
azurepipeline1.yml
resources:
repositories:
- repository: templates
type: git
name: components/pipeline_templates
trigger:
- none
pool:
name: PoolA
variables:
- template: variabletemplates/var.build.yml@templates
jobs:
steps:
- template: CI-CD/dockerbuild.yml@templates # Template reference
parameters:
PATH: ${{ variables.PATH }}
- template: CI-CD/dockerbuild.yml@templates # Template reference
parameters:
PATH: ${{ variables.PATH1 }}
- template: CI-CD/dockerbuild.yml@templates # Template reference
parameters:
PATH: ${{ variables.PATH2 }}
Run Code Online (Sandbox Code Playgroud)
上面的代码有效
但是如果我将参数更改为
parameters:
PATH: ${{ variables.PATH1 }}
OR
parameters:
PATH: ${{ variables.PATH2 }}
Run Code Online (Sandbox Code Playgroud)
在输出中它显示
Output:
docker/path
$(PATH1)
$(PATH2)
Run Code Online (Sandbox Code Playgroud)
我需要在具有不同路径的管道中多次重用模板。请帮助解决问题
您的模板需要一个parameters块。
parameters:
- name: PATH
type: string
steps:
- task: Bash@3
displayName: Build an image to container registry
inputs:
script : echo ${{ parameters.PATH }}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3382 次 |
| 最近记录: |