启动 Azure DevOps 管道时如何提示输入变量?
How can I prompt for variables when launching Azure DevOps pipelines?
我正在尝试让 Azure DevOps 管道在手动启动管道时提示输入版本号(使用新的 YAML 语法定义)。
即使我在模板中定义变量,启动屏幕也会显示“此管道没有定义的变量”。我如何定义变量以便它们出现在管道启动中?
当前 YAML 定义包含:
variables:
- name: versionName
value: ''
启动管道时不显示这些:
来自docs:
If a variable
appears in the variables block of a YAML file, its
value is fixed and can't be overridden at queue time. Best practice is
to define your variables in a YAML file but there are times when this
doesn't make sense. For example, you may want to define a secret
variable and not have the variable exposed in your YAML. Or, you may
need to manually set a variable value during the pipeline run.
You have two options for defining queue-time values. You can define a
variable in the UI and select the option to Let users override this
value when running this pipeline or you can use runtime parameters
instead. If your variable is not a secret, the best practice is to use
runtime parameters.
To set a variable at queue time, add a new variable within your
pipeline and select the override option.
To allow a variable to be set at queue time, make sure the variable
doesn't also appear in the variables
block of a pipeline or job. If
you define a variable in both the variables block of a YAML and in the
UI, the value in the YAML will have priority.
同时 is correct for defining variables, what I was really looking for is runtime parameters.
使用以下 YAML 定义:
parameters:
- name: myParameter
displayName: Description of myParameter
default: defaultMyParameter
type: string
启动管道时提示输入参数值:
必须使用${{ parameters.myParameter }}
在模板中引用参数,其他变量语法无效。
我正在尝试让 Azure DevOps 管道在手动启动管道时提示输入版本号(使用新的 YAML 语法定义)。
即使我在模板中定义变量,启动屏幕也会显示“此管道没有定义的变量”。我如何定义变量以便它们出现在管道启动中?
当前 YAML 定义包含:
variables:
- name: versionName
value: ''
启动管道时不显示这些:
来自docs:
If a
variable
appears in the variables block of a YAML file, its value is fixed and can't be overridden at queue time. Best practice is to define your variables in a YAML file but there are times when this doesn't make sense. For example, you may want to define a secret variable and not have the variable exposed in your YAML. Or, you may need to manually set a variable value during the pipeline run.You have two options for defining queue-time values. You can define a variable in the UI and select the option to Let users override this value when running this pipeline or you can use runtime parameters instead. If your variable is not a secret, the best practice is to use runtime parameters.
To set a variable at queue time, add a new variable within your pipeline and select the override option.
To allow a variable to be set at queue time, make sure the variable doesn't also appear in the
variables
block of a pipeline or job. If you define a variable in both the variables block of a YAML and in the UI, the value in the YAML will have priority.
同时
使用以下 YAML 定义:
parameters:
- name: myParameter
displayName: Description of myParameter
default: defaultMyParameter
type: string
启动管道时提示输入参数值:
必须使用${{ parameters.myParameter }}
在模板中引用参数,其他变量语法无效。