Setting Up an ECS-based Code Development Pipeline
This section describes how to use the built-in code repository of CodeArts to develop, build, and deploy an application.
The deployment is based on Elastic Cloud Server (ECS). This approach is suitable for traditional software packages.
To use container-based deployment, see Setting Up a CCE-based Code Development Pipeline.
Procedure
Step |
Description |
---|---|
Sign up for a HUAWEI ID, enable Huawei Cloud services, and top up your account. Then buy an ECS. |
|
CodeArts is billed yearly or monthly. Buy a package first before using CodeArts. For the operations in this section, enable the Free Edition instead. |
|
Projects are foundational for using CodeArts services. Create a project first before proceeding with subsequent operations. |
|
Use CodeArts Repo to create a repository from the built-in template Java Web Demo. CodeArts Repo helps you manage your project code by version. |
|
Use CodeArts Check to examine your code statically to control quality. |
|
Use CodeArts Build to compile your source code into object files, package them together with configuration and resource files, and then archive them to the release repository. |
|
Use CodeArts Deploy to deploy software packages in the release repository to a VM and then run the application. |
|
Use CodeArts Pipeline to link code check, build, and deployment tasks for continuous delivery. It runs automatically when you update your code. |
|
After completing this practice, delete unused pay-per-use resources to prevent extra charges. |
Preparations
- Purchase an ECS with the following configurations:
- Billing Mode: Select Pay-per-use.
- CPU Architecture: Select x86.
- Specifications: 2 vCPUs | 4 GiB or above, system disk ≥ 80 GiB
- OS: Public image > CentOS 7.6
- EIP: Auto assign
After completing the purchase, add two inbound rules by referring to Configuring Security Group Rules.
- Protocol: TCP; port: 22; source: 0.0.0.0/0
- Protocol: TCP; port: 8080; source: 0.0.0.0/0
Step 1: Enable CodeArts Free Edition
- Go to the Buy CodeArts Package page.
- Select Free, read and agree to the statement, and click Subscribe.
Check the enabling record on the CodeArts page.
Step 2: Create a Project
- Click go to Workspace on the CodeArts console.
- On the CodeArts homepage, click Create > Create Project.
- Select the Scrum template.
- Enter a project name (for example, Demo), and click OK. Keep the name under 128 characters.
The project is created, and the Work Items page is displayed.
Step 3: Create a Code Repository
- In the project, choose Code > Repo from the navigation pane.
- Click Create Repository.
- Select Template and click Next.
- Select the Java Web Demo template and click Next.
- Enter a repository name (for example, Web-Demo), and click OK. Start the name with a letter, digit, or underscore (_), and use letters, digits, hyphens (-), underscores (_), and periods (.). Do not end the name with .git, .atom, or a period.
The repository is created, and its code file list is displayed.
Step 4: Check Code
- In the navigation pane, choose Code > Check.
The automatically created task Web-Demo-check is displayed.
- Click
and choose Settings.
- Choose Rule Sets, and toggle off
next to CSS and HTML.
Figure 1 Editing a rule set - Click Start Check to start the task.
If
is displayed, the task is successful.
If the task fails, rectify the fault by referring to CodeArts Check FAQs.
- Click the Issues tab to view the issue list.
Since there are no critical or major issues, you do not need to modify the code.
Step 5: Build and Archive the Software Package
- In the navigation pane, choose CICD > Build.
The automatically created build task Web-Demo-build is displayed.
- Click
in the row where the task is located to start the task. In the displayed dialog box, confirm the parameter settings and click OK.
If
is displayed, the task is successful.
If the task fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Build FAQs.
- Click the task name to view its details. On the Build History tab, find the latest build ID and record it.
Figure 2 Build ID
- In the navigation pane, choose Artifact > Release Repos.
In the repository view, find the repository with the same name as your project, and go to the Web-Demo-build > Build ID recorded in 3 folder to find the generated software package demoapp.jar.
Figure 3 Viewing the software package
Step 6: Deploy the Build Package
- Configure the target host.
- In the navigation pane, choose Settings > General > Basic Resources.
- Click Create Host Cluster, configure the following information, and click Save.
Table 1 Creating a host cluster Parameter
Example
Description
Cluster Name
host-group
The name of the host cluster to create. Enter 3 to 128 characters, including letters, digits, hyphens (-), underscores (_), and periods (.).
OS
Linux
The OS of the hosts to add to this cluster. Select Linux or Windows.
Host Connection Mode
Direct Connection
The way your target hosts will connect to CodeArts Deploy. Select Direct Connection or Proxy.
Execution Resource Pool
Official
A resource pool (or agent pool) is a collection of physical environments where commands are executed to deploy software packages.
Choose the official agent pool or a self-hosted agent pool that contains your own servers.
- After the system displays a message indicating that the host cluster is created, click Add Host on the Target Hosts tab, select Importing ECS, locate the ECS purchased in Preparations, and click Import.
Figure 4 Importing an ECS
- Configure the following information and click OK.
Table 2 Adding a host Parameter
Example
Description
Username
root
The username for logging in to the ECS. By default, it is root for a Linux ECS.
Password
Enter the password set when you purchase the ECS in Preparations.
The password for logging in to the ECS.
SSH Port
22
The default port is 22. You can also use another one.
- Check the host record. If the Verification Result column shows successful, the host is added.
If the host fails to be added, rectify the fault based on the failure details. For details, see Host Management FAQs.
- Choose CICD > Deploy from the navigation pane.
The automatically created application Web-Demo-deploy is displayed.
- Click
and choose Edit.
- Click the Environment Management tab and configure the host environment.
- Click Create Environment, configure the following information, and click Save.
Table 3 Creating an environment Parameter
Example
Description
Environment
demo-env
The name of the environment to create. Enter 3 to 128 characters, including letters, digits, hyphens (-), underscores (_), and periods (.).
Resource Type
Host
The resource type in the environment. The default value is Host.
OS
Linux
The OS of the hosts to add to this environment. Select Linux or Windows.
- When the system displays a message indicating that the creation is successful, click Import Host on the Resources tab. In the displayed dialog box, select the host cluster and host configured in 1 and click Import.
- When the system shows a success message for the import, close the window.
- Click Create Environment, configure the following information, and click Save.
- Click the Deployment Actions tab and configure actions.
- Install JDK: Check that the JDK version is openjdk-1.8.0.
- Select a Deployment Source: Set the parameters based on the following table.
Table 4 Deployment source configuration Parameter
Example
Description
Source
Build task
The source of the software package to deploy. Select Artifact or Build task.
Build Task
Web-Demo-build
Available only when Source is set to Build task.
Download Path
/usr/local/${package_name}/
The path on your target host for saving the software package.
- Stop SpringBoot: When you run deployments for the first time, this action will fail because Spring Boot has not yet run on the target host. Disable this action by clicking
on the action card and choosing Disable.
Figure 5 Disabling the "Stop SpringBoot" action - Start SpringBoot: Retain the default settings.
- Health Test Through URLs: This action is optional. Disable it for this example.
- Click the Parameters tab and set parameters by referring to the following table.
Table 5 Configuration parameters Name
Default Value
host_group
The environment demo-env added in 4
package_url
Not required for this example. Click
in the same row to delete it.
service_port
8080
package_name
demoapp
- Click Save & Deploy. In the displayed dialog box, confirm the parameter settings and click OK.
Wait until
is displayed on the page. If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.
- View the deployment result.
Open a new browser page and enter http://IP:8080/test. IP indicates the EIP of the ECS purchased in Preparations.
If the following result is displayed, the deployment is successful.
Figure 6 Deployment result
Step 7: Configure a Pipeline
- Choose CICD > Pipeline from the navigation pane.
On the Pipelines tab, the automatically created pipeline Web-Demo-pipeline is displayed.
- Click
and choose Edit.
- On the Task Orchestration tab, configure the pipeline.
- API testing is not involved in this example. So remove the API test task from the pipeline.
Click
next to the Apitest job. In the displayed dialog box, click OK.
Figure 7 Deleting a job - Click the Deploy job, select the build task Build, and keep other parameters the same as those set in Step 6: Deploy the Build Package.
- API testing is not involved in this example. So remove the API test task from the pipeline.
- Click the Execution Plan tab, select Code commit, and select master from the branch filter drop-down list.
Figure 8 Configuring the execution plan
- Click Save.
The updated execution plan is displayed.
- Go to Deploy, edit the deployment actions, and enable Stop SpringBoot.
- Go to the code repository and search for and open the TestController.java file.
Click
, change hello world to hello world again, enter a commit message, and click OK.
Figure 9 Modifying code - Return to the Pipeline page. You can see that the pipeline is running.
When
is displayed, access http://IP:8080/test again. The following figure shows the access result.
If the pipeline fails, click the cause to view logs. Then rectify the fault by referring to CodeArts Pipeline FAQs.
Figure 10 Pipeline execution result
Releasing Resources

Released resources cannot be recovered. Exercise caution when performing these operations.
In this example, the pay-per-use resources involved are from ECS.
If you do not need the ECS after the trial, delete the ECS to release its resources.
Helpful Links
The check, build, deployment, and pipeline tasks used in this section are provided by the repo template. You can create tasks for your own project by referring to the following instructions.
Service |
Method |
---|---|
CodeArts Check |
|
CodeArts Build |
|
CodeArts Deploy |
|
CodeArts Pipeline |
See Creating a Pipeline. |
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