Transferring CodeArts Pipeline Parameters to CodeArts Build and CodeArts Deploy
Overview
Pipeline parameters can be transferred among different services (such as CodeArts Build and CodeArts Deploy). By creating a CI/CD pipeline, you can streamline data of build and deployment.
Procedure
The following describes how to transfer a pipeline version number parameter to a build and a deployment job.
Step 3: Create and Execute a Pipeline
Step 4: Check Build and Deployment Results
Step |
Description |
---|---|
Create a build task |
Create a build task, add the version number parameter, and reference it in the build step. |
Create an application |
Create an application, add a software package parameter, and reference it in the deployment step. |
Create and execute a pipeline |
Create a pipeline, add the version number parameter, and add the created build task and application to the pipeline.
|
Check the build and deployment results |
Check whether:
|
Preparations
- You have created a project. The following uses a Scrum project named Project01 as an example.
- You have created a code repository. The following uses a repository named Repo01 (created using the Java Maven Demo template) as an example.
- You need to prepare a host with an EIP. You can use an existing host or purchase a Huawei Cloud ECS.
Step 1: Create a Build Task
- Log in to the Huawei Cloud console.
- Click in the upper left corner of the page and choose from the service list.
- Click Access Service.
- Click Homepage from the top navigation pane.Search for the project created in Preparations and access the project.
- In the left navigation pane, choose CICD > Build.
- Click Create Task and enter basic information.
Table 2 Basic information Parameter
Description
Name
Build task name. Enter BuildTask01.
Project
Keep the default value, which is the project of the build task.
Code Source
Code source associated with the build task. Select Repo.
Repository
Select the repository Repo01 created in Preparations.
Default Branch
Select master.
- Click Next, select the Maven template, and then click OK.
- On the Parameters tab page, add the releaseversion parameter, set the default value, and enable Runtime Settings.
Figure 1 Creating a build parameter
- On the Build Actions page, click Upload Software Package to Release Repository. For the Version field, enter ${releaseversion}, and retain the default values for other fields.
Figure 2 Configuring build actions
- Click Save.
Step 2: Create an application
- In the left navigation pane, choose , create a host cluster, and add the purchased host to the cluster.
- In the left navigation pane, choose CICD > Deploy.
- Click Create Application. On the displayed page, enter an application name DeployTask01, click Next, select Blank Template, and click OK.
- On the Parameters tab page, add the package_url parameter, set the default value, and enable Runtime Settings.
Figure 3 Creating a deployment parameter
- On the Environment Management page, click Create Environment, enter the name Environment01, and import the host in the cluster to the environment.
- On the Deployment Actions tab page, add the Select Deployment Source action and configure the information as shown in the following table.
Figure 4 Configuring deployment actions
Table 3 Configuring deployment actions Parameter
Description
Action Name
Retain the default value.
Source
Software package source. Select Artifact.
Environment
Environment for deployment. Select Environment01.
Software Package
Software package to be deployed. Obtain the build package uploaded by the build task to Release Repos. Set this parameter to ${package_url} to reference the package_url parameter.
Download Path
Path for downloading the software package to the target host. Enter /usr/local.
Action Control
Retain the default setting.
- Click Save.
Step 3: Create and Execute a Pipeline
- In the navigation pane on the left, choose CICD > Pipeline.
- Click Create Pipeline and configure pipeline information.
- Configure the following basic information and click Next.
Table 4 Pipeline basic information Parameter
Description
Name
Enter Pipeline01.
Code Source
Code source associated with the pipeline. Select Repo.
Repository
Select the repository Repo01 created in Preparations.
Default Branch
Select master.
- Select Blank Template and click OK.
- Configure the following basic information and click Next.
- On the Parameter Configuration tab page, create the releaseversion parameter, set its default value to ${TIMESTAMP}, and enable Runtime Setting.
- On the Task Orchestration page, two stages (Code Source and Stage_1) are generated by default. Click Stage to add a new stage (Stage_2).
Figure 5 Task orchestration
- Add a build job
- Click New Job under the Stage_1.
- Click the Build type and search for the Build extension.
- Move the cursor to the Build extension, click Add, select the created build task, select the repository associated with build task, and set releaseversion to ${releaseversion} to reference the releaseversion parameter of the pipeline.
Figure 6 Adding a build job
- Add an application
- Click Job under Stage_2.
- In the displayed dialog box, search for the Deploy extension.
- Move the cursor to the Deploy extension, click Add, select the created application, enter the package path for package_url, and associate with the added build task, as shown in the following figure.
Figure 7 Adding an application
package_url is the relative path of the build package in Release Repos. The path includes the build task name, version number, and package name. In this section, the pipeline releaseversion parameter indicates the version number.
- Add a build job
- Click Save and Execute.
Step 4: Check Build and Deployment Results
After the pipeline is successfully executed, check whether the pipeline parameter has been transferred to the build and deployment jobs.
- Check the build result
- In the navigation pane on the left, choose Artifact > Release Repos.
- Expand the project navigation tree on the left to check the uploaded build package.
- Check the deployment result
- Click the user name in the upper right corner.
- Click CodeArts Console.
- Click in the upper left corner and search for Elastic Cloud Server. Then, access the Elastic Cloud Server console.
- Locate the ECS used for deployment, click Remote Login in the Operation column.
- In the Other Login Modes area, select Log in using Remote Login on the management console and click Log In.
- Enter the username and password for purchasing the ECS. Press Enter.
- Enter the following command and press Enter to go to the directory /usr/local configured during the Create an Application step.
cd /usr/local
- Enter the following command and press Enter. The deployed build package is displayed as shown in the following figure, which indicates that the pipeline parameter has been successfully transferred.
ls -al
Figure 9 Checking the deployment result
Feedback
Was this page helpful?
Provide feedbackThank 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