Help Center/ CodeArts Check/ Best Practices/ Checking Code with Custom Executors
Updated on 2025-08-01 GMT+08:00

Checking Code with Custom Executors

Scenario

You can register your own executors with CodeArts Check to schedule and execute check tasks. This section describes how to use a custom executor to check code from CodeArts Repo.

This practice depends on CodeArts Repo to store the code.

Constraints

Resource and Cost Planning

In this practice, you need to purchase an ECS as a custom executor. For details about the price of an ECS, see Price Calculator.

Prerequisites

  • You have purchased an ECS.

    Only EulerOS 2.5 is supported for custom executors.

  • You have installed Git-LFS on the custom executor. If not, install it by referring to the following command-based example.
    Run the following commands on the executor:
    # Download
    wget -O  git-lfs.tar.gz https://github.com/git-lfs/git-lfs/releases/download/v3.4.1/git-lfs-linux-amd64-v3.4.1.tar.gz
    # Decompress the package
    tar -zxvf git-lfs.tar.gz
    # Open the directory generated after the decompression
    cd  git-lfs-3.4.1
    # Run the installation script
    sh install.sh
    # Verify
    git lfs version
  • You have attached an EVS disk.

Procedure

Table 1 Steps

Step

Description

Creating a Project

Create a project.

Creating an Agent Pool

Create a pool of custom executors (agent pool).

Creating a CodeArts Repo Repository

Create a repository to store code.

Configuring and Executing a Check Task

Configure the task to use the custom executor.

Viewing Check Results

View the check logs to verify the executor used for the task.

Creating a Project

  1. Log in to the Huawei Cloud console.
  2. Click in the upper left corner and choose Developer Services > CodeArts Check from the service list.
  3. Click Go to CodeArts Check to go to the CodeArts Check homepage.
  4. In the navigation pane, choose Homepage. Click Create > Create Project, and select the Scrum template.
  5. Enter the project name, for example, check-bestpractice. Retain the other parameters as default.
  6. Click OK to access the project.

Creating an Agent Pool

  1. On the navigation bar, click the username and choose All Account Settings.
  2. Choose Agent Management > Agent Pool.
  3. Click Create Pool. In the displayed dialog box, set parameters according to Table 2 and click Save.

    Table 2 Agent pool configuration

    Parameter

    Description

    Pool Name

    Assign a custom name to the pool, for example, custom_pool.

    Pool Type

    Select LINUX_DOCKER. When a task is initiated, a Linux Docker container will be started to run the task.

    Description

    (Optional) Enter additional information to describe the pool.

    This pool can be used by all users of the current account.

    (Optional) Selecting this option allows all users within the current account to use the pool.

  4. Click the name of the new pool (custom_pool is used in this practice). The pool configuration page is displayed.
  5. Click Create Agent. In the displayed dialog box, configure the agent according to Table 3 and leave the other parameters as default.

    Table 3 Parameters for creating an agent

    Parameter

    Description

    Install Docker

    Selecting this option mandates Docker installation.

    Install Docker automatically

    Toggling on the switch will automatically install Docker.

    AK

    Obtain an AK.

    SK

    Obtain an SK.

    Agent Name

    Assign a custom name to the agent, for example, agent_test_custom.

    Agent Workspace

    Enter an agent workspace that follows the standard Linux directory structure. For example, /opt/agent_test_custom.

  6. Select the check box to confirm that you have read and accept the agreements. Then click Generate Command and Copy Command. Click Close.

    Figure 1 Creating an agent

  7. Go to the ECS list page, find the row of the ECS purchased to meet prerequisites, click Remote Login, and run the command copied in 6, as instructed by Step 3.
  8. On the agent list page, click Refresh List. After the information is automatically synchronized in the background, a new item will be added to the list. The agent alias is agent_test_custom-mwlye1NlLG.

Creating a CodeArts Repo Repository

  1. In the navigation pane, choose Code > Repo to go to the CodeArts Repo page of the check-bestpractice project.
  2. Click Create Repository and select CR.
  3. On the displayed page, select Template and click Next.
  4. On the template selection page, select the Java Maven Demo template and click Next.
  5. On the displayed page, set Repository Name to custom_repo, select Automatically create Check task, and leave the other parameters as default. Click OK.

    Figure 2 shows the directory that stores files of the code repository.

    Figure 2 Directory that stores files of the code repository

Configuring and Executing a Check Task

  1. In the navigation pane, choose Code > Check. The task is displayed on the task list page, because you have selected Automatically create Check task when creating a cloud repository in CodeArts Repo.
  2. Click the task name. On the displayed page, choose Settings > Custom Environment.
  3. In the Execution Host area, select Self-Hosted.
  4. Expand the drop-down list and select custom_pool you created in Creating an Agent Pool.
  5. Click Save and click Start Check.

Viewing Check Results

Click the task name. On the displayed task details page, click Logs. If the logs contain "Find available executor node:agent_test_custom-mwlye1NlLG," the task is executed by a custom executor. agent_test_custom-mwlye1NlLG is the agent alias mentioned in 8.

Related Operations