Common variable groups

更新时间:
复制 MD 格式

Create and manage common variable groups at the organization level to centralize global variable configuration. Associate these groups with pipelines to make the variables available to specific pipeline jobs.

Manage common variable groups

Create a common variable group

On the Flow home page, click , and then click Create Variable Group.

Enter a Variable Group Name, Variable Group ID (auto-generated), Description, Variable Name, and Default Value. Click Create.

Note
  • Private mode hides a variable's value from view.

  • To protect a secret key, once private mode is enabled for a variable, it cannot be disabled.

Edit a common variable group

On the Flow home page, click . Find the target variable group and click Edit Variable Group on the right.

Delete a common variable group

On the Flow home page, click . Find the target variable group and click Delete Variable Group on the right.

Note

If a variable group is associated with any pipelines, deleting it may cause those pipelines to fail. Confirm the association status before you proceed.

Use common variable groups

Common variable groups define a set of variables that can be referenced across multiple pipeline stages or jobs. Variable values are dynamically substituted at runtime.

Use variable groups in pipelines

  1. Create a common variable group and define its variables. On the Global Settings page, select Common Variable Group from the left navigation pane and click Create Variable Group. In the Create Common Variable Group dialog box, enter the Variable Group Name (for example, NAMESPACE), Variable Group ID, and Description. Then, in the variable list, click Add Variable to configure each variable's Variable Name, Default Value, and Private Mode toggle. Click Create.

  2. Associate the common variable group with your pipeline. On the pipeline editing page, click Variables and Caching > Common Variable Group. In the upper-right corner, click Associate Variable Group. In the drop-down panel, select the variable group to link (for example, NAMESPACE), and then click OK.

  3. Reference variables in any pipeline job by using the ${variable_name} syntax.

    For example, add a Get Defined Common Variables job to the build stage. In the Run Command step, enter echo ${vpc01} and echo ${vpc02} to reference variables from the group.

  4. The commands echo ${vpc01} and echo ${vpc02} will print the variable values. An output of test01 and test02, respectively, confirms that the variables from the common variable group were accessed successfully.