Help Center/ CodeArts Pipeline/ Getting Started/ Generating a Software Package and Deploying It on a Host Through CodeArts Pipeline
Updated on 2024-11-08 GMT+08:00

Generating a Software Package and Deploying It on a Host Through CodeArts Pipeline

CodeArts Pipeline is a visualized and automated job scheduling platform. It needs to be used together with automated jobs of services such as CodeArts Build, CodeArts Check, CodeArts TestPlan, and CodeArts Deploy. You can orchestrate these automated jobs as needed. A single configuration triggers executions repeatedly to avoid inefficient manual operations.

In this section, we will create a pipeline to sequentially run code checks, build the software package, and deploy it on a host.

Figure 1 Basic operation process

Prerequisites

Preparations

  1. Create a project

    1. Log in to the Huawei Cloud console.
    2. Click in the upper left corner of the page and choose Developer Services > CodeArts Pipeline from the service list.
    3. Click Access Service to access the CodeArts Pipeline homepage.
    4. On the top navigation bar, click Homepage. On the displayed page, click Create Project, select Scrum, and enter a name Project01.
    5. Click OK.

    For details, see Creating a Scrum Project and a Work Item.

  2. Create a code repository and a code check task.

    1. Click the created project to access it, choose Code > Repo from the left navigation pane.
    2. Click New Repository, select Template, and select the Java Maven Demo template.
    3. Click Next and enter the repository name Repo01.

      A code check task with the same name as the code repository is automatically created. Change the task name to CheckTask01 by referring to Creating a Task.

    4. Click OK.

    For details, see Creating a Repository Using a Template.

  3. Create a build task

    1. In the left navigation pane, choose CICD > Build.
    2. Click Create Task and configure task information.
      1. Enter a name BuildTask01, select the code source Repo, select the created repository, select the default branch master, and click Next.
      2. Select the system template Maven, click OK. On the displayed Build Actions tab page, retain the default configurations.
    3. Click Save.

    For details, see Creating a Build Task.

  4. Create an application

    1. In the left navigation pane, choose Settings > General > Basic Resources, create a host cluster, and add the purchased host to the cluster.
    2. In the left navigation pane, choose CICD > Deploy.
    3. Click Create Application. On the displayed page, enter an application name DeployTask01, click Next, select Blank Template, and click OK.
    4. On the Deployment Actions tab page, add the Select Deployment Source action and configure the following information.
      • Source: Set the source to Build task
      • Environment: Click Create. On the displayed Environment Management page, click Create Environment to import the host to the environment.
      • Build task: Select the created build task.
      • Download path: Enter the deployment directory of the host. In this example, the directory is /usr/local/.
      • Retain default settings for other parameters.
    5. Click Save.

    For details, see Creating an Application with a Blank Template.

Create a pipeline

  1. Access the created project, choose CICD > Pipeline from the left navigation pane.
  2. Click Create Pipeline and configure pipeline information.

    1. Configure the following information and click Next.
      Table 1 Pipeline basic information

      Parameter

      Configuration

      Name

      Enter Pipeline01.

      Code Source

      Select Repo.

      Repository

      Select the created repository.

      Default Branch

      Select master.

    2. Select Blank Template and click OK.

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

    1. Add a code check task
      1. Click New Job under Stage_1.
      2. Click the Check type and search for the Check extension.
      3. Move the cursor to the extension, click Add, select the created code check task, and set Check Mode to Full.
      Figure 2 Adding a code check task
    2. Add a build task
      1. Click Parallel Job under Stage_1, or click under the code check job.

        The code check job and build job can be in parallel or serial.

      2. Click the Build type and search for the Build extension.
      3. Move the cursor to the extension, click Add, select the created build task, and select the repository associated with the build task.
      Figure 3 Adding a build task
    3. Add an application
      1. Click Job under Stage_2.
      2. In the displayed dialog box, search for the Deploy extension.
      3. Move the cursor to the extension, click Add, select the created application, and associate it with the added build task.
      Figure 4 Adding an application

  4. After the configuration, click Save.

Executing a Pipeline

  1. Return to the pipeline list page and click in the Operation column.
  2. In the displayed dialog box, retain the default settings, and click Execute.
  3. Click the pipeline name to go to the Execution History page.
  4. Click the execution message to check pipeline execution situation in real time.

    Click a job card to view its log.

Checking the Pipeline Execution Result

  1. Click the avatar in the upper right corner.
  2. Click CodeArts Console.
  3. Click in the upper left corner and search for Elastic Cloud Server. Then, access the Elastic Cloud Server console.
  4. Locate the ECS used for deployment, click Remote Login in the Operation column.
  5. In the Other Login Modes area, select Log in using Remote Login on the management console and click Log In.
  6. Enter the username and password for purchasing the ECS. Press Enter.
  7. Enter the following command and press Enter to go to the directory /usr/local configured during application creation.

    cd /usr/local

  8. Enter the following command and press Enter to check the deployed package.

    ls -al
    Figure 5 Checking the pipeline execution result

Related Information

CodeArts Pipeline provides built-in templates for you to quickly create pipelines. For more information, see Managing Pipeline Templates.