Help Center/ CodeArts Pipeline/ Best Practices/ Configuring Pass Conditions for Automated Code Checks
Updated on 2025-08-13 GMT+08:00

Configuring Pass Conditions for Automated Code Checks

Overview

Traditional software quality relies mainly on manual tests, leading to low efficiency.

CodeArts Pipeline uses pass conditions to control whether a pipeline can proceed to the next stage. You can apply policies to pipelines as pass conditions for efficient project management and high-quality delivery.

With CodeArts Pipeline, more than 70% issues can be intercepted through automated code checks. This improves test efficiency and software quality.

Procedure

The following describes how to configure code check thresholds and apply pass conditions to a stage for automated check.

Figure 1 Pipeline workflow

Perform the following procedure.

Table 1 Procedure

Step

Description

Billing

Create a rule and configure thresholds

Create a rule of the code check type and configure thresholds for the rule.

Upgrade the CodeArts package to the basic edition. For details, see CodeArts Billing Modes.

Create a policy and add the rule to the policy

Add the preceding code check rule to the created policy.

Upgrade the CodeArts package to the basic edition. For details, see CodeArts Billing Modes.

Configure a pipeline

Add the preceding policy to the pass conditions.

No billing involved.

Execute the pipeline

Execute the pipeline:

  • If the code check job meets the pass conditions, the pipeline will continue to run.
  • If the code check job does not meet the pass conditions, the pipeline will stop running.

No billing involved.

Preparations

Step 1: Create a Rule and Configure Thresholds

  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.
  4. Click the avatar icon in the upper right corner and choose All Account Settings from the drop-down list.
  5. In the navigation pane on the left, choose Policy Management > Rules.
  6. Click Create Rule. On the displayed page, configure parameters.

    Figure 2 Creating a rule
    Table 2 Rule parameters

    Parameter

    Description

    Name

    Enter a rule name, such as Check_code.

    Type

    Select the rule type Check.

    Extension

    Select the extension Check.

    Version

    Select the version 0.0.1.

    Threshold Configuration

    The extension thresholds are automatically filled based on the selected extension version. You can use the default values.

  7. Click OK.

Step 2: Create a Policy and Add a Rule to the Policy

There are tenant-level policies and project-level policies. Tenant-level policies can be applied to pipelines of all projects under the current tenant, while project-level policies can be applied to all pipelines under the current project. The following uses a tenant-level policy as an example.

  1. In the navigation pane on the left, choose Policies.

    A system policy exists by default. You can view and use the policy, but cannot edit or delete it.

  2. Click Create Policy. On the displayed page, enter a policy name and select the rule created in Step 1: Create a Rule and Configure Thresholds.

    Figure 3 Creating a policy

  3. Click OK.

Step 3: Configure a Pipeline

  1. On the top navigation bar, click Homepage.
  2. Search for the project created in Preparations and access the project.
  3. In the navigation pane on the left, choose CICD > Pipeline.
  4. Search for the pipeline created in Preparations, click in the Operation column, and select Edit. The Task Orchestration page is displayed.
  5. Click under Stage_1, select From empty, add the code check task created in Preparations, set Check Mode to Full, and click OK.

    Figure 4 Adding a code check task

  6. Click under Stage_1, on the displayed window, add Pass-Conditions-of-Standard-Policies, and select the policy created in Step 2: Create a Policy and Add a Rule to the Policy.

    Figure 5 Adding pass conditions

  7. Click or to add a new stage for the pipeline, add the build task created in Preparations, select the associated repository for the build task, and click OK.

    Figure 6 Adding a build task

Step 4: Execute the Pipeline

  1. After configuring the pipeline, click Save and Execute.
  2. Check the execution result.

    • If the code check job meets the pass conditions, the pipeline will proceed to the next stage, as shown in the following figure.
      Figure 7 Executing a pipeline
    • If the code check task does not meet the pass conditions, the pipeline will stop running, as shown in the following figure. You can click the pass conditions card to check details.
      Figure 8 Executing a pipeline