Help Center/ CodeArts Build/ Best Practices/ Applying Custom Parameters to Another Build Task
Updated on 2026-09-15 GMT+08:00

Applying Custom Parameters to Another Build Task

Scenario

You need to create a temporary password and use it in other build tasks.

These steps depend on the following services:

Requirements

  • You have permissions for CodeArts Repo.
  • You have permissions for CodeArts Pipeline.

Procedure

Table 1 Procedure

Step

Description

Creating a Project

Create a project.

Creating a CodeArts Repo Repository

Create a code repository.

Creating a Parameter Group

Create a temporary username and password.

Creating a Build Task

Create a build task.

Creating and Running a Pipeline Task

Create a pipeline task.

Viewing the Build Results

Check the running result of this practice.

Creating a Project

  1. Log in to the Huawei Cloud console with your Huawei Cloud account.
  2. Click in the upper left corner and choose Developer Services > CodeArts from the service list.
  3. Click Access Service. The homepage of CodeArts is displayed.
  4. Click Create Project, and select the Scrum template.
  5. Set the project name to build-bestpractice, and leave the other parameters as default.
  6. Click OK to access the project.

Creating a CodeArts Repo Repository

  1. In the navigation pane, choose Code > Repo.
  2. On the displayed page, click New Repository. Select Template, and click Next.
  3. On the template selection page, select the Java Maven Demo template and click Next.
  4. On the repository creation page, type parameters_repo in the Repository Name field, and leave the other parameters as default.
  5. Click OK. The code repository details page is displayed. Figure 1 shows the directory that stores files of the code repository.

    Figure 1 Directory

Creating a Parameter Group

  1. In the navigation pane, choose CICD > Pipeline.
  2. Click the Parameter Groups tab and then click Create Group.

  3. On the page for creating a parameter group, set Parameter Group Name to temp_pwd and create it.
  4. Add the pipeline_user parameter and set its default value to User. Add the pipeline_pwd parameter and set its default value to Password. Then, click OK.

Creating a Build Task

  1. In the navigation pane, choose CICD > Build.
  2. Access CodeArts Build. Click Create Task. On the displayed Basic Information page, set the following parameters. Leave the other parameters as default.

    • Name: Assign a custom name to the build task, for example, parameters_task.
    • Code Source: Select the code source from which code will be pulled for this build. In this practice, select Repo.
    • Repository: Select parameters_repo, the code repository created in Creating a CodeArts Repo Repository.

  3. Click Next. On the displayed page, select Blank Template. Click OK. The Build Actions page is displayed.
  4. On the Build Actions tab page, click Add Build Actions and add the Run Shell Commands action.

  5. In the command window of the Run Shell Commands action, enter the following commands:

    echo ${build_user}
    echo ${build_pwd}

  6. Switch to the Parameters tab page and click Create Now.

  7. Add the custom parameters build_user and build_pwd. The default values are empty. Runtime Settings is enabled.

  8. Click Save in the upper right corner of the page. In the dialog box that is displayed, confirm it.

Creating and Running a Pipeline Task

  1. In the navigation pane, choose CICD > Pipeline.
  2. On the pipeline service page, click Create Pipeline. Set the pipeline task name to parameters_pipeline and retain the default values for other parameters.
  3. Click Next, select Blank Template, and confirm it. The pipeline task configuration page is displayed.
  4. Go to the page for editing the pipeline task in Creating a Parameter Group.
  5. Switch to the Parameter Configuration > Parameter Groups tab page.

  6. Click Associate Now, select the name of the parameter group created in Creating a Parameter Group, and click Confirm.

  7. Switch to the Task Orchestration tab page and click New Job under Stage_1.

  8. On the page for creating a task, click New Job. In the dialog box that is displayed, click Build > Add.

  9. Select the build task parameters_task created in Creating a Build Task from the Select Task drop-down list, and select the repository parameters_repo created in Creating a CodeArts Repo Repository.

    Set build_user to ${pipeline_user} and build_pwd to ${pipeline_pwd}. This indicates that the parameters used by the current build task come from the parameter group.

  10. Click Execute. In the displayed dialog box, click OK.

Viewing the Build Results

  1. After the pipeline task is successfully executed, choose CICD > Build in the navigation pane.
  2. In the Step Logs of the parameters_task build task, click Run Shell Commands. If the username and password set in the parameter group are displayed on the console, the current build task uses the username and password in the parameter group. You can also use the username and password in the parameter group in other build task tasks.