Gate merge requests in Codeup with pipeline-based automated checks to prevent unreviewed code from merging. This topic shows you how to create a pipeline merge check from scratch.
Create a pipeline merge check
Before you begin, make sure you have a Codeup repository with at least one open merge request, and that your account has access to Alibaba Cloud DevOps to configure branch protection rules and create pipelines.
In a merge request, click . You are redirected to the Branch Settings page in Alibaba Cloud DevOps.
-
On the Branch Settings page, click New branch protection rule. Set the Branch scope, configure Push rules and Merge rules as needed, then enable Require automated status checks to pass before merging.
Enabling this option reveals two sub-options: - Code Detection Task — runs code scanning powered by the Codeup code scanning service. - Pipeline Check — runs a pipeline powered by Alibaba Cloud DevOps Flow. Select one or both depending on the checks you want to enforce.
In the Pipeline Check section, click New pipeline.
-
On the Select a pipeline template page, choose a template that matches your project's language and build needs.
Select a template category from the left panel (for example, Java). The right panel shows matching templates such as Java · Test, Build, Java · Test, Build, Deploy to Alibaba Cloud Function Compute (FC), and Java · Test, Build Image. Select a template and click Create.
-
In the pipeline editor, enable the Enable Code Source Trigger toggle.
Configure the following trigger options:
Code submission — triggers the pipeline when code is pushed to the branch.
Merge request created/updated — triggers the pipeline when the merge request is opened or updated.
Enable branch or tag filtering, then set the target branch of the merge request (for example,
master) as the filter. This prevents the pipeline from running against unrelated branches.
-
Configure the test tasks in the Test stage.
Add tasks such as Java Code Scan and Maven Unit Test. For each task, configure the following settings in the editor panel on the right: - Task Name: A descriptive name for the task. - Build Cluster: Select a cluster such as Alibaba Cloud DevOps Beijing Build Cluster. - Specify Build Node: Select the node type, for example Linux/amd64. - Build Environment: Select Specify container environment and set the container image address to
build-steps/alinux3. - Download Pipeline Source: Configure how the pipeline fetches your source code. - Task Steps: Add the steps to run, such as Java Code Convention Scan. Click Save and Run in the upper-right corner when done. -
Return to the New branch protection rule panel, select the pipeline you just created, and save the branch protection rule.
Make sure Require automated status checks to pass before merging is enabled and Pipeline Check is selected. From the list of associated pipelines, select your target pipeline (for example, pipeline-2024-12-10), then click Save.
-
Go back to the Merge Request page. Any update to the merge request now automatically triggers the configured checks.
On the Automated Checks tab, track the execution status of the associated pipeline. A passing run shows Java Code Scan passed (Total: 0, Blocker: 0, Critical: 0, Major: 0) and Maven Unit Test passed, with the status bar showing No code conflicts. Once all automated checks pass, click Merge in the upper-right corner to complete the merge.