Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I create pipeline variables for a YAML-based pipeline?

Tags:

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.

like image 598
Greg Avatar asked May 16 '19 18:05

Greg


People also ask

How do you use variables in YAML pipeline?

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.

How do I add a variable group to YAML pipeline?

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.

How do you pass variables in Azure pipelines YAML tasks?

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.


1 Answers

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:

enter image description here

and there you would be able to define variables, and they would have a checkbox - Settable at queue time.

like image 170
4c74356b41 Avatar answered Oct 19 '22 07:10

4c74356b41