Updated on 2024-10-15 GMT+08:00

Orchestrating Pipeline Stages

A stage is a basic part of a pipeline. Jobs can be orchestrated and managed in different stages. Closely associated jobs can be managed in one stage for intuitive workflows.

Configuring Stages

  1. Access the CodeArts Pipeline homepage.
  2. On the pipeline list page, search for the target pipeline, click in the Operation column, and click Edit.
  3. On the Task Orchestration tab page, click or Stage to add a stage to the pipeline. After a stage is added, you can edit, clone, delete, move it, or configure its entry type.

    Table 1 Stage management

    Operation

    Description

    Editing a stage

    Click . In the displayed window, you can configure the stage name and whether to always run jobs in the stage.

    • Always Run: If you select Yes, jobs in this stage will be executed and cannot be canceled.
    • Always Run: If you select No, jobs will be selected by default but can be deselected.

    Cloning a stage

    Click to clone a pipeline stage.

    Deleting a stage

    Click and confirm the deletion as prompted.

    Sorting a stage

    Click and drag to adjust the stage sequence.

    Setting the entry type

    You can set in what conditions can a pipeline proceed to the next stage. Click . In the displayed window, configure the entry type.

    • Automatic (default): The pipeline automatically proceeds to the next stage.
    • Manual: The pipeline proceeds only after manual confirmation.
    • Time window: The pipeline proceeds to the next stage within a specified period.

    Pass conditions

    You can set rules and policies to decide in what conditions can a pipeline complete the current stage.

    • Rules determine whether to pass an extension output by comparing its relationship with a threshold, and a policy is composed of multiple such rules. For details, see Configuring a Rule.
    • A policy is a set of rules and can be applied to multiple pipelines. There are tenant-level policies and project-level policies. Policies control pipeline runs and ensure high-quality delivery.
    NOTE:
    • Only Pass-Conditions-of-Standard-Policies is available. You can select a created policy.
    • You can set exclusive pass conditions for each stage.
    • You can set multiple pass conditions for one stage.
    1. Click Pass Conditions under a stage. In the displayed window, move the cursor to the pass conditions card and click Add.
    2. Enter a name and select a policy.

    3. Click OK.

  4. After the configuration, save the pipeline.

Configuring a Rule

Rules are tenant-level resources and can be used in all tenant- or project-level policies of the current tenant.

  1. Access the CodeArts Pipeline homepage.
  2. Click the username in the upper right corner and click All Account Settings.
  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 2 Rule parameters

    Parameter

    Description

    Name

    Rule name, which is generated based on the current time. Enter only letters, digits, underscores (_), and hyphens (-) with a maximum of 128 characters.

    Type

    Rule type, which corresponds to the extension type. Supported extension types: Build, Check, and Test.

    • Build: extensions for code build.
    • Check: extensions for code check.
    • Test: extensions for API tests.

    Extension

    All extensions of the selected type.

    • Extensions of the Build type: Set thresholds for build results. For example, you can select the official Build extension to set thresholds for the Maven unit test.
    • Extensions of the Check type: Set thresholds for code check results. For example, you can select the official Check extension to set thresholds for code check issues.
    • Extensions of the Test type: Set thresholds for test results. For example, you can select the official TestMan extension to set thresholds for the test case pass rate in test suites.

    Version

    Extension versions that allow for threshold settings.

    Threshold Configuration

    (Optional) Automatically generated based on the selected extension version. Note that if you changed threshold settings, the relevant rule and policy would also be changed.

    NOTE:

    If you set the relationship to Exclude or Include, Text is usually used. For the check item Pass Ratio, the value ranges from 0 to 1.

  5. Click Confirm to create a rule. You can also perform the following operations in the rule list.

    • On the rule list page, click in the Operation column to edit a rule.
      • The rule type cannot be edited.
      • After a rule is edited, all policies that reference the rule are automatically modified.
    • On the rule list page, click in the Operation column. On the displayed dialog box, confirm the deletion.

      After a rule is deleted, all policies that reference the rule automatically cancel the reference.

Configuring the Tenant-level Policy

Tenant-level policies are tenant-level resources and can be used in pass conditions for all pipelines of the current tenant.

  1. Access the CodeArts Pipeline homepage.
  2. Click the username in the upper right corner and click All Account Settings.
  3. In the navigation pane on the left, choose Policy Management > Policies. The policy list page is displayed.

    There is a system policy by default. You can check and use the policy, but cannot edit or delete it.

  4. Click Create Policy and set parameters.

    Table 3 Policy parameters

    Parameter

    Description

    Name

    Policy name, which is generated based on the current time by default. Enter only letters, digits, underscores (_), and hyphens (-) with a maximum of 128 characters.

    Rule

    The selected rules will be displayed in the right part of the page. You can perform the following operations on each rule:

    • Edit: Click Detail in the upper right corner of the rule to check details. Click Edit in the upper right corner to edit the rule.
    • Enable/Disable: You can click the toggle in the upper right corner to enable/disable the rule. After the rule is disabled, it will not take effect in the pass conditions.
    NOTE:

    A maximum of 20 rules can be selected for a policy.

  5. Click Confirm to create a policy. You can also perform the following operations in the policy list.

    • Click to edit a policy.
    • Click to check a policy. Click Edit in the upper right corner to edit the policy.
    • Click and select Clone to clone a policy.
    • Click and select Delete. On the displayed dialog box, confirm the deletion.

      When you delete a policy, the system displays a message indicating the number of pipelines that use the policy. Once the policy is deleted, pipeline execution will fail.

    • Click the toggle to enable or disable a policy.

      If a policy is disabled, the system displays a message indicating the number of pipelines that use the policy. Once the policy is disabled, it will not take effect in the pass conditions.

Configuring Project-level Policies

Project-level policies are project-level resources and can be used in pass conditions for all pipelines of the current project.

  1. Access the CodeArts Pipeline homepage through a project.
  2. Click the Policies tab.
  3. On the displayed page, click Create Policy.

    Table 4 Policy parameters

    Parameter

    Description

    Name

    Policy name, which is generated based on the current time by default. Enter only letters, digits, underscores (_), and hyphens (-) with a maximum of 128 characters.

    Rule

    The selected rules will be displayed in the right part of the page. You can perform the following operations on each rule:

    • Edit: Click Detail in the upper right corner of the rule to view the details. Click Edit in the upper right corner to edit the rule.
    • Enable/Disable: You can click the toggle in the upper right corner to enable/disable the rule. After the rule is disabled, it will not take effect in the pass conditions.
    NOTE:

    A maximum of 20 rules can be selected for a policy.

  4. Click Confirm to create a policy.

    • On the policy list page, click to edit a policy. You can also perform the following operations in the policy list.
    • Click to check a policy. Click Edit in the upper right corner to edit the policy.
    • Click and select Clone to clone a policy.
    • Click and select Delete. On the displayed dialog box, confirm the deletion.

      When you delete a policy, the system displays a message indicating the number of pipelines that use the policy. Once the policy is deleted, pipeline execution will fail.

    • Click to enable or disable a policy.

      If a policy is disabled, the system displays a message indicating the number of pipelines that use the policy. Once the policy is disabled, it will not take effect in the pass conditions.

    • On the policy list page, click Tenant Policies in the upper right corner. In the displayed window, you can view, clone, or inherit a tenant-level policy.
      • View: Click in the Operation column to check the tenant-level policy. Click Edit in the upper right corner to edit the tenant-level policy.
      • Clone: Click in the Operation column to clone a project-level policy based on the selected tenant-level policy.
      • Inherit: Click in the Operation column to inherit a project-level policy from the tenant-level policy. The inherited rules are always consistent with rules of the tenant-level policy.