Configuring a Pipeline Gate for a Code Repository Merge Request
Overview
You can set an automated pipeline gate for merge requests in code repositories. By doing so, every merge request that triggers a pipeline will go through code checks, builds, or tests in the pipeline. Only code that has passed strict code review can be merged into the main branch. This mechanism ensures code stability and reliability, and effectively reduces production environment issues caused by code defects. Overall, this solution improves code quality and CI/CD efficiency.
Preparations
- You have enabled and authorized CodeArts Pipeline.
- You have created a project. The following uses a Scrum project named Project_Test as an example.
- You have created a code repository and created a branch. The following uses a repository named Repo_Test (created using the Java Maven Demo template) and a branch named release-1.0.0 as an example.
Process
- Log in to the Huawei Cloud console.
- Click
in the upper left corner of the page and choose from the service list.
- Click Access Service.
- Click Create Pipeline and configure pipeline information as shown in Table 1.
Table 1 Parameters Parameter
Example Value
Description
Name
Pipeline-Test
Pipeline name.
Project
Project_Test
Project that a pipeline belongs to.
Pipeline Source
Repo
Pipeline source associated with the pipeline.
Repository
Repo_Test
Code repository associated with the pipeline.
Default Branch
release-1.0.0
Default branch of the repository.
- After configuring the basic information, click Next. On the displayed Select Template page, select Blank Template and click OK.
- Go to the Task Orchestration page. Two stages (Pipeline Source and Stage_1) are generated by default. You can add code check or build jobs as needed.
- Click the Execution Plan tab and configure Repo trigger events. Select Merge request, set events, filter branches, and filter paths. For details, see Configuring Event Triggers.
- Access the Repo_Test repository created in Preparations, choose Settings > Policy Settings > Merge Requests. In the Branch Policies area, click Create Branch Policy, select or enter a branch, select Enable pipeline gate, and click OK.
- Click the Merge Requests tab. On the displayed page, create a merge request in Repo_Test to trigger the pipeline. The pipeline running status will be displayed in the Merge Conditions area.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot