With designer/class build pipeline, you can define pipeline variables with default values to be passed into the tasks. How do I do the same for a YAML-based pipeline?
I want to create three build pipelines, each would have a single variable set to a different value. All three point to a single YAML file. The documentation states:
You can choose which variables are allowed to be set at queue time and which are fixed by the pipeline author. If a variable appears in the variables block of a YAML file, it is fixed and cannot be overridden at queue time. To allow a variable to be set at queue time, make sure it doesn't appear in the variables block of a pipeline or job. You can set a default value in the editor, and that value can be overridden by the person queuing the pipeline.
It's not clear how to do this for YAML file.
I can create a template YAML file, and an individual YAML file for each config value that calls the template file, but then I can't set configuration value at run-time.
In YAML pipelines, you can set variables at the root, stage, and job level. You can also specify variables outside of a YAML pipeline in the UI. When you set a variable in the UI, that variable can be encrypted and set as secret. User-defined variables can be set as read-only.
Create a variable group You can't create variable groups in YAML, but they can be used as described in Use a variable group. Sign in to your organization ( https://dev.azure.com/{yourorganization} ) and select your project. Select Pipelines > Library > + Variable group. Enter a name and description for the group.
Passing variables between tasks in the same jobSet the value with the command echo "##vso[task. setvariable variable=FOO]some value" In subsequent tasks, you can use the $(FOO) syntax to have Azure Pipelines replace the variable with some value.
when you edit the build definition (not when you create it, at least with default experience). you'd need to click on 3 dots and pick variables
from the list:
and there you would be able to define variables, and they would have a checkbox - Settable at queue time
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With