Updated on 2024-03-20 GMT+08:00

Using CodeArts

This section describes the basic operation process of CodeArts.

Figure 1 Basic operation process

Prerequisites

  1. You have purchased CodeArts. For details, see Purchasing CodeArts.
  2. To deploy applications on a host, you need to prepare a host with an EIP. You can use an existing host or purchase a Huawei Cloud ECS.

Configuring a Project

CodeArts Req is the basis for using services on CodeArts. You need to create a project, add project members, and add work items based on your project plan.

  1. Create a project.

    1. Log in to the CodeArts console.
    2. Click and select a region.
    3. Click Access Service.
    4. Click Create Project.
    5. Click Scrum, enter a project name, and click OK.

  2. Add a project member.

    1. Go to the created project, and choose Settings > General > Members from the navigation pane.

      In the upper right of the list, click Add Members or Invite via Links.

      You can add members in any of the following ways:

      • Add users in your enterprise
      • Import users from other projects
      • Invite users from other enterprises
      • Import users from agencies
      Figure 2 Adding members

  3. Create a work item.

    1. Click a project, choose Work, and click the Work Items tab.
    2. Click Create Work Item, select a work item type, and enter information such as the title, priority, and handler.

For more operations on CodeArts Req, see CodeArts Req User Guide.

Configuring a Code Repository

The code repository is based on Git to manage versions of project code. Therefore, you need to install the Git client locally in advance.

  1. Install and configure the Git client.

    1. Download the installation package from the Git website and install the Git client with the default configurations on the local host.
    2. Run Git Bash and enter the following commands to configure the username and email address:
      1
      2
      git config  --global user.name "<name>"
      git config  --global user.email "<email_address>"
      
    3. Generate a pair of SSH keys: The generated key is stored in ~/.ssh/id_rsa.pub.
      1
      ssh-keygen -t rsa -C "email_address"
      
    4. Display the key content.
      cat ~/.ssh/id_rsa.pub

  2. Create a code repository.

    1. Go to the created project and choose Code > Repo.
    2. Click New Repository.
    3. Select Common, Template, or Import, and click Next.
    4. Enter the basic information such as the repository name, and click OK.
    5. After a code repository is created, click the repository name on the repository list page to view the files in the repository.

  3. Clone or push code.

    1. Click the username in the upper right corner of the page and choose This Account Settings from the drop-down list.
    2. In the navigation bar, choose Repo > SSH Keys.
    3. Click Add SSH Key, enter the name, enter the key generated in Installing and Configuring the Git Client, agree to statements, and click OK.
    4. Return to the CodeArts Repo page and click the name of the repository to be cloned.
    5. Click Clone/Download to copy the repository SSH download link.
    6. Run Git Bash and enter the following command to clone the cloud repository to your local address:
      1
      git clone repository_SSH_URL
      
    7. After editing the code locally, enter the following commands in sequence in Git Bash to save the code and push it to the code repository:
      1
      2
      3
      git add .
      git commit -m "commit_message"
      git push origin master
      
    8. Return to CodeArts Repo to view the updated file.

For more operations on CodeArts Repo, see CodeArts Repo User Guide.

Configuring a Pipeline

CodeArts Pipeline integrates with CodeArts Check, CodeArts Build, and CodeArts Deploy tasks. You can flexibly configure tasks in the pipeline as required. The pipeline is optional.

  • CodeArts Check performs static and security checks. The code check is optional.
  • CodeArts Build compiles the source code of software into a target file and packs the configuration file and resource file. Build is optional. For some projects, such as PHP and Node.js frontend code, you do not need to configure build tasks.
  • CodeArts Deploy deploys a software package or code to a VM or container. Deployment is optional. For some projects, such as mobile app development, this deployment mode is not required.
  1. Create a code check task.

    1. Go to the created project and choose Code > Check.
    2. Click Create Task, select the code repository to check, and click New next to the repository name.
    3. Enter the created task, go to the Overview tab page and click Start Check.
    4. After the task is successfully executed, you can view the check result, issues, and suggestions.

    For more operations on CodeArts Check, see CodeArts Check User Guide.

  2. Create a build task.

    1. Go to the created project and choose CICD > Build in the navigation bar.
    2. Click Create Task and configure task information as required.
      1. Basic information: Configure the following information and click Next.
        Table 1 Basic information

        Item

        Suggestion

        Task Name

        Enter a custom name.

        Code Source

        Select Repo.

        Source Code Repository

        Select the code repository created in Configuring a Code Repository.

        Branch

        Select a repository branch as required.

      2. Build Template: You can select a built-in or Blank Template and click Next.
    3. Configure the build actions, parameters, execution plan. Click Create and Run.
    4. After the task is complete, you can view the build result and logs.

    For more operations on CodeArts Build, see CodeArts Build User Guide.

  3. Create and deploy an application.

    1. Go to the created project. In the navigation bar, choose Settings > General > Basic Resources, create a host cluster, and add the hosts prepared in Prerequisites to the cluster.
    2. Go to the created project and choose CICD > Deploy from the navigation bar.
    3. Click Create Application and configure task information as required.
      1. Basic information: Enter a custom application name and click Next.
      2. Select a deployment template. You can select a built-in or Blank Template. Then click OK.
    4. Configure the deployment actions, parameters, and environments as required, and click Save & Deploy.
    5. After the application is successfully deployed, you can view the deployment result, logs, and error information on the page.

      For more operations on CodeArts Deploy, see CodeArts Deploy User Guide.

  4. Configure a pipeline.

    1. Go to the created project and choose CICD > Pipeline from the navigation bar.
    2. Click the Pipelines tab, click Create Pipeline, and configure pipeline information.
      1. Basic information: Configure the following information and click Next.
        Table 2 Pipeline basic information

        Item

        Suggestion

        Project

        Enter a custom name.

        Pipeline Source

        Select Repo.

        Repository

        Select the code repository created in Configuring a Code Repository.

        Default Branch

        Select a repository branch as required.

      2. Template: Select a built-in or Blank Template. Then click Confirm.
    3. Configure the task orchestration, parameters, and execution plan as required, and click Save and Run.
    4. After the task is successfully executed, click it to view details.

    For more operations on CodeArts Pipeline, see CodeArts Pipeline User Guide