我正在尝试将由步骤组成的模板中输出的变量传递到同一作业中的另一个步骤模板,设置如下所示,
错误:
semVersion 参数值不是有效值
jobs:
- job: job_git_tag
displayName: Tag new version
steps:
- template: /templates/git/semantic_version_type.yaml
parameters:
semVersion: ${{ parameters.semVersion }}
- template: /templates/git/git_tag.yaml
parameters:
module: ${{ parameters.module }}
semVersion: $(Type.Semversion)
模板语义版本
parameters:
- name: semVersion
type: string
default: auto
values:
- major
- minor
- patch
- auto
steps:
- ${{ if eq(variables['Build.Reason'], 'PullRequest') }}:
- bash: |
### do some scripting magic and output variable
echo "##vso[task.setvariable variable=semVersion;isOutput=true]major"
displayName: Get semantic version type
name: Type
Git 标签模板
parameters:
- name: module
type: string
- name: semVersion
type: string
default: patch
values:
- major
- minor
- patch
steps:
- bash: |
### here the repository is checkedout and tagged with the correction version after being bumped.
displayName: Tag new version
parameters
在compile time
在管道运行之前进行评估,不支持将第一个模板中的变量值作为第二个模板的参数传递。
作为替代方案,您可以删除第二个模板的
semVersion: $(Type.Semversion)
,直接在模板中调用它。
jobs:
- job: job_git_tag
displayName: Tag new version
steps:
- template: /templates/git/semantic_version_type.yaml
parameters:
semVersion: ${{ parameters.semVersion }}
- template: /templates/git/git_tag.yaml
parameters:
module: ${{ parameters.module }}
第二个模板:
parameters:
- name: module
type: string
# - name: semVersion
# type: string
# default: patch
# values:
# - major
# - minor
# - patch
steps:
- bash: |
echo $(Type.Semversion)
displayName: Tag new version
我这边输出: