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

Setting Up a CCE-based Code Development Pipeline

This section describes how to use the built-in code repository of CodeArts to develop, build, and deploy an application.

This chapter uses Cloud Container Engine (CCE) for container-based deployment. To use traditional software package deployment, see Setting Up an ECS-based Code Development Pipeline.

Procedure

Step

Description

Preparations

Sign up for a HUAWEI ID and enable Huawei Cloud services. Top up your account. Buy a Cloud Container Engine (CCE) cluster and create a SoftWare Repository for Container (SWR) organization.

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: Prepare a Dockerfile

Create a Dockerfile. It is a text file that contains the instructions and descriptions required for building an image. For details about Dockerfile, see the Docker official website.

Step 5: Build an Image and Push It to SWR

Run a build task to compile the software source code into an image and archive the image to SWR.

Step 6: Create a Workload

Create a Deployment in CCE to load and run the demo image.

Step 7: Deploy the Image

Create an application in CodeArts Deploy to automate image deployment.

Step 8: Configure a Pipeline

Configure a pipeline to integrate the code repository, build, and deployment. When a code commit action occurs in the code repository, the pipeline is automatically executed for continuous delivery.

Releasing Resources

After completing this practice, delete unused pay-per-use resources to prevent extra charges.

Preparations

  • Buy a CCE cluster that meets the requirements listed in the following table.
    Table 1 Cluster configuration requirements

    Category

    Configuration

    Reference

    Cluster

    Pay-per-use recommended

    • Type: CCE Standard Cluster
    • Cluster Version: Select the latest version.
    • Controller Node Architecture: X86
    • Network Model: VPC network
    • Container CIDR Block: Auto select

    Buying a CCE Standard/Turbo Cluster

    Node

    Pay-per-use recommended

    • Node Type: Elastic Cloud Server (VM)
    • Specifications: 2 vCPUs | 8 GiB or above
    • Container Engine: Docker
    • OS: Public image > CentOS 7.6

    Creating a Node

  • Create an organization named web-demo in SWR. If this name is already in use, enter another. For details, see Creating an Organization.

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: Prepare a Dockerfile

  1. Click a repository name to go to the repository.
  2. Click Create above the file list. Select Create File from the drop-down list.

    Figure 1 Creating a file

  3. Enter the file name Dockerfile and then enter the following code:

    FROM openjdk:8-alpine
    ADD target /demo
    COPY ./target/demoapp.jar /demo
    CMD ["java","-jar","/demo/demoapp.jar"]

  4. Enter a commit message and click OK.

Step 5: Build an Image and Push It to SWR

  1. In the navigation pane, choose CICD > Build.
  2. Click Create Task and configure the task information.

    1. Basic Information: Configure the following information and click Next.
      Table 2 Basic information

      Parameter

      Example

      Description

      Name

      Web-Demo-docker

      Build task name. Use a maximum of 115 characters, including letters, digits, underscores (_), and hyphens (-).

      Code Source

      Repo

      Select Repo, GitHub, or other sources.

      Repository

      Web-Demo

      The code repository to compile.

      Default Branch

      master

      The repository branch to compile.

    2. Select Template: Select Blank Template and click OK.

  3. Configure build actions.

    1. Click Add Build Actions, find Build with Maven in the list, and click Add.
    2. Click Add Action. In the action list, find Build Image and Push to SWR, and click Add.
    3. Configure Build Image and Push to SWR by referring to the following table. (Retain the default values for the fields not listed in this table.)
      Table 3 Configuring image information

      Parameter

      Example

      Description

      Organization

      Name of the organization created in Preparations

      The organization to which the image will belong after being pushed to SWR.

      Image Tag

      v1.0.0

      Image version. Use a maximum of 128 characters, including letters, digits, periods (.), underscores (_), and hyphens (-). Do not start with a period or hyphen.

  4. After the configuration is complete, click Save and Run.

    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.

  5. Log in to the SWR console. In the navigation pane, choose My Images.

    There is a record whose Name is demo and Organization is web-demo.

    Click the image name to view details. The image version is v1.0.0.

    Figure 2 Viewing images

Step 6: Create a Workload

  1. Log in to the CCE console and click the cluster purchased in Preparations to go to the details page.
  2. Choose Workloads in the navigation pane, and click Create Workload.
  3. Complete the configurations by referring to the following table and click Create Workload.

    For details about the parameters, see Creating a Deployment.
    Table 4 Creating workload

    Category

    Parameter

    Example

    Basic Info

    Workload Type

    Deployment

    Workload Name

    web-demo

    Pods

    1

    Container Settings

    Image Name

    Click Select Image. In the dialog box that is displayed, select demo and click OK.

    Pull Policy

    Always

    Image Tag

    v1.0.0

    Advanced Settings

    Upgrade Mode

    Replace upgrade

  4. When the creation is complete, click View Workload Details to go back to the details page. A record is displayed on the Pods tab.

    If the pod status is Running, click the Access Mode tab, click Create Service, configure the service by referring to the following table, and click OK.

    For details about the parameters, see Creating a LoadBalancer Service.

    If the pod status is abnormal, rectify the fault by referring to Workload Abnormalities.

    Table 5 Configuring access mode

    Parameter

    Example

    Service Name

    web-demo

    Service Type

    LoadBalancer

    Service Affinity

    Cluster level

    Load Balancer

    1. Choose Shared > Auto create.
    2. Configure the following parameters:
      • Instance Name: web-demo-test
      • EIP: Auto create

    Port

    • Protocol: TCP
    • Container Port: 8080
    • Service Port: 8080

    After the creation is successful, a new record is displayed in the list.

  5. Refresh the page, and check the access mode list. When is displayed, hover over the load balancer name in the Service Type column, and copy the public IP address in the pop-up window.

    Figure 3 Copying the access address

  6. Open a new browser page and enter http://IP:8080/test in the address box. Replace IP with the public IP address copied in 5.

    If the following information is displayed, the workload is running properly.

    Figure 4 Deployment result

Step 7: Deploy the Image

  1. Return to the CodeArts page, and choose CICD > Deploy from the navigation pane.

    1. Click Create Application, enter an application name (for example, web-demo-k8s), and click Next. The name can contain 3–128 characters, including letters, digits, hyphens (-), and underscores (_).
    2. Select Blank Template and click OK.

  2. Search for and add action Kubernetes Quick Deployment (CCE cluster). Configure this action by referring to the following table.

    Table 6 Configuring deployment actions

    Parameter

    Example

    Description

    Region

    The region where the cluster purchased in Preparations is located

    The region of the target cluster.

    Cluster Name

    The name of the cluster purchased in Preparations.

    The name of the target cluster.

    Namespace

    default

    The namespace of the target cluster.

    Workload

    web-demo

    The workload to deploy.

    Container

    The container name displayed in the Container Settings area involved in Step 6: Create a Workload

    The name of the container to deploy the workload in.

  3. Click Save & Deploy.

    If is displayed, the test is successful. If the deployment fails, rectify the fault based on the failure step and the error message in logs. For details, see CodeArts Deploy FAQs.

Step 8: Configure a Pipeline

  1. Choose CICD > Pipeline from the navigation pane.
  2. Click Create Pipeline and configure the pipeline.

    1. Basic Information: Configure the following information and click Next.
      Table 7 Pipeline basic information

      Parameter

      Example

      Description

      Name

      pipeline-web-demo

      Pipeline name. Use a maximum of 128 characters, including letters, digits, hyphens (-), and underscores (_).

      Pipeline Source

      Repo

      The code source of the pipeline. Select Repo, Git, or other sources.

      Repository

      Web-Demo

      The code repository to be associated with the pipeline.

      Default Branch

      master

      The repository branch to be associated with the pipeline.

    2. Template: Select Blank Template and click OK.

  3. Configure the workflow.

    1. Click next to Stage_1. In the Edit Stage dialog box, enter a stage name and click Confirm. The name can contain 1–128 characters, including letters, digits, spaces, and special characters (-_,;:./()). Do not start or end with a space.
      Figure 5 Editing the stage name
    2. Click Parallel Job, and select From empty. The job creation window is displayed on the right.
    3. Locate Build in the list and click Add.
      Figure 6 Adding a job
    4. Configure the job information by referring to the following table and click OK.
      Table 8 Editing a build job

      Parameter

      Example

      Description

      Name

      Retain the default value.

      Job name. Use 1–128 characters, including letters, digits, spaces, and special characters (-_,;:./()). Do not start or end the name with a space.

      Select Task

      Web-Demo-docker

      Select a build task whose code source is pipeline or the same repository as the pipeline you are configuring.

      Repository

      Web-Demo

      Select the code repository associated with the build task.

    5. Click Stage and change the stage name to Deploy. The new stage is displayed.
    6. Click New Job and add the Deploy extension.
    7. Select the web-demo-k8s task (or application), associate the build task set in 3.d, and click OK.

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

    Figure 7 Configuring the execution plan

  5. Click Save.

    The updated execution plan is displayed.

  6. 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 8 Modifying code

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

If you do not need CCE after the trial, delete the pay-per-use cluster to release its resources.