Help Center/ CodeArts Pipeline/ User Guide/ CodeArts Release User Guide/ Configuring an Environment Variable
Updated on 2024-10-15 GMT+08:00

Configuring an Environment Variable

You can use ${variable name} to reference an environment variable when creating or editing a release policy, or use {{variable name}} to reference an environment variable in YAML files. Environment variables include:

  • Custom variables: can be added as needed. Currently, only variables of the string type are supported.
  • Default variables: system parameters, which cannot be deleted or modified.
    Table 1 Default variables

    Variable

    Description

    ARTIFACT

    Artifact path. In the deployment YAML file, use {{ARTIFACT}} to reference the build artifacts.

    TIMESTAMP

    Timestamp when the extension is executed. For example, 20230401095436.

    PROJECT_ID

    ID of the project to which the environment belongs.

Configuring an Environment Variable

  1. Access the release environment list page.
  2. Click an environment name. The Environment Information page is displayed.
  3. Click the Environment Variable tab.
  4. Click Edit Variable to add a variable and set parameters.

    Table 2 Parameters for creating a custom variable

    Parameter

    Description

    Variable

    Variable name. Enter only letters, digits, underscores (_), and hyphens (-) with a maximum of 128 characters.

    Type

    Only the string type is supported.

    Value

    The current value of a variable, or empty if you are adding a new variable. The value contains no more than 512 characters.

    Change Value

    Updated value of the environment variable.

    Description

    Variable description. It can contain a maximum of 128 characters.

    Private Variable

    If a parameter is private, the system encrypts the parameter for storage and decrypts the parameter for usage. Private parameters will not be displayed in run logs.

    • Click in the Operation column to delete a variable.
    • Click to add a variable.

  5. After setting all parameters, click Save. The Save Changes dialog box is displayed.
  6. Confirm the variable information, enter the remarks, and click OK.

    You can click the Versions tab to check variable versions.

    • Click a version name to view the variable details.
    • Click in the Operation column to compare the current version with a specified version.

Using an Environment Variable

You can use environment variables in the following scenarios:

  • When configuring a release policy, you can use ${variable name} to reference an environment variable in the YAML path, for example, the workload YAML path in the rolling upgrade task.
    Figure 1 Referencing an environment variable
  • Use {{variable name}} to reference an environment variable in the YAML configuration file associated with the release policy.
    Figure 2 Referencing an environment variable