Step 8: Configuring a Pipeline for CD
CodeArts Pipeline provides a visualized and customizable software pipeline for automatic delivery and supports multiple task types, such as code check, build, and deployment tasks.
As the project progresses, each stage (build, release, and deployment) becomes more and more standardized. However, each stage is relatively independent and is semi-finished and cannot deliver business value directly. Only by effectively connecting each stage to form a complete continuous delivery (CD) pipeline can we truly improve the efficiency and quality of software release and continuously create business value.
This section describes how Chris, a developer, connects code check, building, and deployment for CD.
Introduction to Preset Pipelines
There are five pipeline tasks preset in the sample project. You can view and use them as needed.
Preset Pipeline Task |
Description |
---|---|
phoenix-workflow |
A basic pipeline task |
phoenix-workflow-test |
Pipeline task corresponding to the test environment |
phoenix-workflow-work |
Pipeline task corresponding to the Worker function |
phoenix-workflow-result |
Pipeline task corresponding to the Result function |
phoenix-workflow-vote |
Pipeline task corresponding to the Vote function |
- For details about Vote, Result, and Worker, see Solution Architecture.
Configuring and Executing a Pipeline
A pipeline usually consists of multiple stages. You can add multiple jobs to each stage.
- Configure a pipeline.
- Go to the Phoenix Mall project and choose .
- Find pipeline phoenix-workflow. Click and click Edit.
- Add a code check stage.
- Click between the pipeline source and build to add a stage.
- Click next to Stage_1. In the Edit Stage window, enter the stage name Check and click Confirm.
Figure 1 Editing the stage name
- Click NewJob.
In the NewJob window, click Add next to the Check extension.
- Select the phoenix-codecheck-worker task and click OK.
The check task has three modes. This procedure uses the default mode Full. You can change the mode as required.
- Full: All files in the code repository are scanned.
- Incremental (last commit): Incremental check is performed based on the latest commit file.
- Incremental (last success): Incremental check is performed based on the changed files since the latest access control was passed.
- Configure a deployment task.
Click the deployment task name, select the associated build task phoenix-sample-ci, and check the values of configuration items.
- The configurations of task phoenix-sample-standalone must be the same as those on the Parameters page of the task with the same name in Deploy.
- The configurations of task phoenix-cd-cce must be the same as those on the Parameters page of the task with the same name in Deploy.
Two deployment tasks are added in this example. If you selected only one deployment mode in preceding steps, keep the corresponding task and delete the other one.
- Go to the CCE console. Locate the target cluster, click , click the Deployments tab, and verify that no record exists in the list.
If there are records in the list, select all records, click Delete, select all options, and click Yes to clear the records in the list.
- Return to the pipeline list page. Click in the row where phoenix-sample-pipeline is located, and click Run in the window that is displayed to start the pipeline.
If is displayed on the page, the task is successfully executed.
If the task fails to be executed, check the failure cause in the failed task. You can open the step details page to view the task logs and rectify the faults based on the logs.
Configuring Pass Conditions
To control the code quality, the code must be scanned and the number of errors must be within a reasonable range before being released. By adding quality access control, you can effectively automate the control process.
- On the phoenix-sample-pipeline details page, click in the upper right corner and choose Edit from the drop-down list.
- In the Check stage, click Pass Conditions.
- In the Pass Conditions dialog box, click Add next to Pass-Conditions-of-Standard-Policies.
- Select System Policy and click OK.
- Click Save and Run.
If the number of check issues does not reach the threshold, the pipeline task fails to be executed.
For details about how to manage pass conditions, see Rules and Policies.
Configuring Code Changes to Automatically Trigger Pipelines
Through the following configuration, code changes can automatically trigger pipeline execution, implementing continuous project delivery.
- On the phoenix-sample-pipeline details page, click in the upper right corner to edit.
- Click the Schedule tab, select Run upon Code Commit in the Event Triggering Directory area, select master from the Branch Filter drop-down list box, and click Save.
- Verify the configuration result: Modify the code and push it to the master branch to check whether the pipeline task is automatically executed.
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