Help Center/ CodeArts/ Getting Started/ Setting Up an ECS-based Code Development Pipeline
Updated on 2025-07-01 GMT+08:00

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

Preparations

Sign up for a HUAWEI ID, enable Huawei Cloud services, and top up your account. Then buy an ECS.

Step 1: Enable CodeArts Free Edition

CodeArts is billed yearly or monthly. Buy a package first before using CodeArts. For the operations in this section, enable the Free Edition instead.

Step 2: Create a Project

Projects are foundational for using CodeArts services. Create a project first before proceeding with subsequent operations.

Step 3: Create a Code Repository

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.

Step 4: Check Code

Use CodeArts Check to examine your code statically to control quality.

Step 5: Build and Archive the Software Package

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.

Step 6: Deploy the Build Package

Use CodeArts Deploy to deploy software packages in the release repository to a VM and then run the application.

Step 7: Configure a Pipeline

Use CodeArts Pipeline to link code check, build, and deployment tasks for continuous delivery. It runs automatically when you update your code.

Releasing Resources

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

  1. Go to the Buy CodeArts Package page.
  2. Select Free, read and agree to the statement, and click Subscribe.

    Check the enabling record on the CodeArts page.

Step 2: Create a Project

  1. Click go to Workspace on the CodeArts console.
  2. On the CodeArts homepage, click Create > Create Project.
  3. Select the Scrum template.
  4. 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

  1. In the project, choose Code > Repo from the navigation pane.
  2. Click Create Repository.
  3. Select Template and click Next.
  4. Select the Java Web Demo template and click Next.
  5. 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

  1. In the navigation pane, choose Code > Check.

    The automatically created task Web-Demo-check is displayed.

  2. Click and choose Settings.
  3. Choose Rule Sets, and toggle off next to CSS and HTML.

    Figure 1 Editing a rule set

  4. 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.

  5. 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

  1. In the navigation pane, choose CICD > Build.

    The automatically created build task Web-Demo-build is displayed.

  2. 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.

  3. 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

  4. 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

  1. Configure the target host.

    1. In the navigation pane, choose Settings > General > Basic Resources.
    2. 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.

    3. 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
    4. 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.

    5. 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.

  2. Choose CICD > Deploy from the navigation pane.

    The automatically created application Web-Demo-deploy is displayed.

  3. Click and choose Edit.
  4. Click the Environment Management tab and configure the host environment.

    1. 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.

    2. 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.
    3. When the system shows a success message for the import, close the window.

  5. 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.

  6. 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

  7. 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.

  8. 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

  1. Choose CICD > Pipeline from the navigation pane.

    On the Pipelines tab, the automatically created pipeline Web-Demo-pipeline is displayed.

  2. Click and choose Edit.
  3. On the Task Orchestration tab, configure the pipeline.

    1. 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
    2. 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.

  4. Click the Execution Plan tab, select Code commit, and select master from the branch filter drop-down list.

    Figure 8 Configuring the execution plan

  5. Click Save.

    The updated execution plan is displayed.

  6. Go to Deploy, edit the deployment actions, and enable Stop SpringBoot.
  7. 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

  8. 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.

Table 6 Task creation instructions

Service

Method

CodeArts Check

See Creating a Task to Check Code from Repo.

CodeArts Build

See Creating a Build Task.

CodeArts Deploy

See Creating an Application.

CodeArts Pipeline

See Creating a Pipeline.