Creating a Pipeline with YAML
Creating a Pipeline with YAML
- Access the CodeArts Pipeline homepage.
- Click Create Pipeline. Configure parameters by referring to Table 1.
Table 1 Pipeline basic information Parameter
Description
Name
Enter a pipeline name. Enter only letters, digits, underscores (_), and hyphens (-) with a maximum of 128 characters.
Project
Project that a pipeline belongs to.
- If you access CodeArts Pipeline through the homepage, select a project as needed.
- If you access CodeArts Pipeline through a project, the parameter cannot be changed.
Code Source
Select Repo (CodeArts Repo). It provides comprehensive code hosting services for enterprises and Git-based online code hosting services for software developers.
NOTE:You can only use Repo to create a YAML-based pipeline.
Orchestration Method
Select YAML: Use YAML to orchestrate a pipeline (one YAML file can be used for multiple pipelines). Syntax auto-completion and validation are available.
Repository
Code repository associated with the pipeline.
Default Branch
Branch used when a pipeline is executed manually or at a specified time.
Configuration File
- New: Create a YAML file.
- Existing: Orchestrate a pipeline based on the existing YAML file. The orchestrated content will overwrite the original YAML file. For details about how to compile a YAML file, see YAML Syntax.
YAML File
This parameter is mandatory when Configuration File is set to Existing.
Select a branch and enter the relative path of the YAML file.
Repo Endpoint
Configure an endpoint to enhance permissions for Repo. Endpoints are used for change-triggered pipelines and repository operation extensions. You can select an endpoint created in Preparations or click Create one to create an endpoint. For details, see Creating Service Endpoints.
Alias
After you set a repository alias, system parameters will be generated based on the alias. For example, Alias_REPOSITORY_NAME indicates the repository name. You can check the generated parameters on the Parameter Configuration page and reference them in a pipeline in the format of ${Parameter name}.
Description
Enter a maximum of 1,024 characters.
- After configuring the basic information, click OK. The Task Orchestration page is displayed.
- You can edit the YAML file on the left. For details, see YAML Syntax.
- You can add extensions to the YAML file from the extension list displayed on the right.
You can verify YAML syntax during orchestration. Click Preview to switch to the graphical user interface.
- After orchestration, click Save, enter the commits message, and push commits in one of the following ways:
- Push commits to the existing branch: If you created the pipeline with a new YAML file, commits will be pushed to the default branch. If you created a pipeline with an existing YAML file, commits will be pushed to the branch where the YAML file resides.
- Push commits to a new branch: Commits will be pushed to a new branch. If you selected Create merge request, a merge request will be created for the new branch and the existing branch.
- Click Confirm.
YAML Syntax
- Example
The following YAML outlines a pipeline configuration. It consists of a build, a code check, and a deployment job in serial mode, and references pipeline parameters in the build job.
env: # Define environment variables as key-value pairs. Environment variables can be referenced in any job within the pipeline. image_version: 1.0.0 jobs: # Define jobs included in the pipeline. build: # Job ID, which defines the unique identifier of the job. name: maven build # Job name, which is displayed on the GUI. steps: # Define the steps within the job. - name: My build step # Step name, which is displayed on the GUI. uses: CodeArtsBuild # Extension used for this step. with: # Define the extension's runtime parameters as key-value pairs. Variables defined in "env" can be referenced. jobId: 878b4d13cb284d9e8f33f988a902f57c artifactIdentifier: my_image version: ${{ env.image_version }} check: name: code check steps: - name: My check step uses: CodeArtsCheck with: jobId: 43885d46e13d4bf583d3a648e9b39d1e checkMode: full deploy: name: cce deploy needs: # Specify that this job should run only after the listed jobs have completed. - build - check if: ${{ completed() }} # Specify the condition under which this job should run. steps: - name: My deploy step uses: CodeArtsDeploy with: jobId: 9c5a5cda6ffa4ab583380f5a014b2b31 version: ${{ env.image_version }}
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