Help Center> CodeArts Pipeline> Best Practices> Configuring Pass Conditions for Pipelines
Updated on 2024-06-11 GMT+08:00

Configuring Pass Conditions for Pipelines

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.

Traditional automotive enterprises mainly rely on manual tests, leading to low efficiency.

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

Procedure

You can add pass conditions for a stage where there is a code check task. If the code check result meets the pass conditions, the pipeline continues to run. Perform the following procedure.

Preparations

Step1: Create a Rule and Configure Thresholds

  1. Log in to CodeArts.
  2. Click the avatar icon in the upper right corner and choose All Account Settings from the drop-down list.
  3. In the navigation pane on the left, choose Policy Management > Rules.
  4. Click Create Rule. On the displayed page, configure parameters.
    Figure 1 Creating a rule
    Table 1 Rule parameters

    Parameter

    Description

    Name

    Enter a rule name, for example rule01.

    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.

  5. Click Confirm.

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 policy01 and select the rule rule01 created in step 1.
    Figure 2 Creating a policy
  3. Click Confirm.

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. In stage 1, add the code check task created in Preparations, click , add Pass-Conditions-of-Standard-Policies, and select the policy policy 01 created in step 2.
    Figure 3 Adding pass conditions
  6. Click or to add a new stage for the pipeline and add the build task created in Preparations to the new stage.
    Figure 4 Configuring a pipeline

Step 4: Execute the Pipeline

  1. After configuring the pipeline, click Save and Run.
  2. After execution, the code check task passes the verification and the pipeline proceeds to the next stage.
    Figure 5 Executing a pipeline