Updated on 2023-12-21 GMT+08:00

Configuring Build Parameters

By default, the codeBranch parameter and predefined parameters are generated for a build task. You can modify the type and value of codeBranch and add custom parameters as required. Predefined parameters and values are automatically generated and can be referenced using ${parameter_name}.

Parameter Settings

  1. Log in to the CodeArts Build homepage.
  2. Search for the target build task.
  3. In the row of the target build task, click and choose Edit from the drop-down list.
  4. Switch to the Parameters tab.

    The parameters are described in the following table.

    Basic Information

    Description

    Name

    codeBranch and predefined parameters are generated by the system and their names cannot be changed. You can change the names of other custom parameters.

    Type

    Parameter types include string and enumeration.

    Default Value

    Default values are provided for different types of parameters. You can change the values as required.

    Private Parameter

    If a parameter is private, the system encrypts the input for storage and only decrypts the parameter when using it. Private parameters are not displayed in run logs.

    Runtime Settings

    If this function is enabled, parameters can be changed when a build task is executed independently and will be reported to the pipeline. Runtime parameters need to be entered during execution.

    • Add a string parameter

      Click Create Parameter. A string parameter is added by default. You can edit the parameter as required.

    • Add an enumeration parameter
      1. Click Create Parameter. A string parameter is added by default.
      2. Click next to the type and select Enumeration from the drop-down list. The Enumeration dialog box is displayed.
      3. Set values for the parameter. Each value must end with a comma (,).
      4. After the setting is complete, select a value from the drop-down list in the Default Value column.

Using Parameters

This section describes how to use custom and predefined parameters.

  • Custom parameters
    1. Configure an execution parameter.

      Edit the build task, click the Parameters tab, add a parameter with a custom name and value (in this example, set the name to myparam and value to 1.0.1.1), and enable Runtime Settings.

    2. Use the execution parameter.

      Switch to the Build Actions tab, configure a build action, enter ${myparam} in the Version text box, and save the build task.

    3. Run the build task.

      In the displayed dialog box for setting parameters and running the task, enter a value or use the default value.

    4. Query the build package of this task in CodeArts Artifact. (It is assumed that this build task is built with Maven and CodeArts Artifact is enabled.)

      Go to the release repo and find the build package. The version of this package is the value of myparam.

  • Predefined parameters
    1. Configure an execution parameter.
      Edit the build task, click the Build Actions tab, configure a build action, enter ${BUILDNUMBER} in the Version text box, and save the build task.

      Parameter

      Description

      BUILDNUMBER

      Build ID in the format of date.times that this build task run on that day. For example: 20200312.3.

      GIT_COMMIT

      Code commit ID. For example: b6192120acc67074990127864d3fecaf259b20f5.

      TIMESTAMP

      Build running timestamp. For example: 20190219191621.

      INCREASENUM

      Total number of times that the task is run. The value starts from 1 and is incremented by 1 each time the task is run.

      PROJECT_ID

      Project ID.

      WORKSPACE

      Workspace, which is the root directory of the source code.

      GIT_TAG

      Code tag name. The tag has a value only when used for build.

    2. Run the build task.
    3. Query the build package of this task in release repos. (It is assumed that this build task is built with Maven and CodeArts Artifact is enabled.)

      Go to the release repo and find the build package. The version of this package is the value of BUILDNUMBER.