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:
- CodeArts Repo: stores your project code.
- CodeArts Pipeline: You can customize common parameters.
Requirements
- You have permissions for CodeArts Repo.
- You have permissions for CodeArts Pipeline.
Procedure
| Step | Description |
|---|---|
| Create a project. | |
| Create a code repository. | |
| Create a temporary username and password. | |
| Create a build task. | |
| Create a pipeline task. | |
| Check the running result of this practice. |
Creating a Project
- Log in to the Huawei Cloud console with your Huawei Cloud account.
- Click
in the upper left corner and choose from the service list. - Click Access Service. The homepage of CodeArts is displayed.
- Click Create Project, and select the Scrum template.
- Set the project name to build-bestpractice, and leave the other parameters as default.
- Click OK to access the project.
Creating a CodeArts Repo Repository
- In the navigation pane, choose .
- On the displayed page, click New Repository. Select Template, and click Next.
- On the template selection page, select the Java Maven Demo template and click Next.
- On the repository creation page, type parameters_repo in the Repository Name field, and leave the other parameters as default.
- Click OK. The code repository details page is displayed. Figure 1 shows the directory that stores files of the code repository.
Creating a Parameter Group
- In the navigation pane, choose .
- Click the Parameter Groups tab and then click Create Group.

- On the page for creating a parameter group, set Parameter Group Name to temp_pwd and create it.
- 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
- In the navigation pane, choose .
- 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.
- Click Next. On the displayed page, select Blank Template. Click OK. The Build Actions page is displayed.
- On the Build Actions tab page, click Add Build Actions and add the Run Shell Commands action.

- In the command window of the Run Shell Commands action, enter the following commands:
echo ${build_user} echo ${build_pwd}
- Switch to the Parameters tab page and click Create Now.

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

- 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
- In the navigation pane, choose .
- On the pipeline service page, click Create Pipeline. Set the pipeline task name to parameters_pipeline and retain the default values for other parameters.
- Click Next, select Blank Template, and confirm it. The pipeline task configuration page is displayed.
- Go to the page for editing the pipeline task in Creating a Parameter Group.
- Switch to the tab page.

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

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

- On the page for creating a task, click New Job. In the dialog box that is displayed, click .

- 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.
- Click Execute. In the displayed dialog box, click OK.
Viewing the Build Results
- After the pipeline task is successfully executed, choose in the navigation pane.
- 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.

What is your overall rating for this page?
Thank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot
