Creating a Build Task
Preparations
(These preparations apply only when you are defining your build with YAML.)
Write a YAML file and place it in the .cloudbuild directory of the code repository. For details about how to write a YAML file, see YAML File Structure for a Single Task.
If the YAML file is not stored in the .cloudbuild directory, you can set the CB_BUILD_YAML_PATH parameter to specify the path of the YAML file in the code repository. For details about parameter settings, see (Optional) Configuring Build Task Parameters.
Configuring Basic Information
- Create a project by referring to "Scrum Projects" > "Creating a Scrum Project" in CodeArts Req User Guide.
- Create a code repository. For details, see "Creating a CodeArts Repo Repository" in CodeArts Repo User Guide.
- Log in to the CodeArts Build homepage.
- Click Create Task. On the displayed Basic Information page, configure the build task information. For graphical builds, see Table 1. For YAML builds, see Table 2.
Table 1 Configuring basic information for a graphical build Parameter
Description
Name
Enter a task name.
Project
Select the project that the task belongs to.
Code Source
- Repo: Code is pulled from the current project's repository for your build.
- Pipeline: If is selected as a code source, the build task can only be triggered by a corresponding pipeline and cannot run on its own.
The following options allow you to pull code from third-party repositories. If this is your first time using any of these sources, you must create a service endpoint in advance. For details, see (Optional) Creating a Service Endpoint.
- Git: Code is pulled from other services for your build.
Repository
Select a code repository.
Default Branch
Select a default branch.
Description
Enter additional information to describe the task.
Table 2 Configuring basic information for a YAML build Parameter
Description
Name
Enter a task name.
Project
Select the project that the task belongs to.
Code Source
If you select Repo, code is pulled from CodeArts Repo for your build.
Repository
Select a code repository.
Default Branch
Select a default branch.
Description
Enter additional information to describe the task.
Configuring a Build Template
- Click Next. The page for selecting a build template is displayed.
- Select a build template.
- Graphical build: Select a build template suitable for your project.
You can also select Blank Template and add desired build actions. If the preset templates do not meet your needs, you can also create a custom one.
- YAML build: Select Blank Template.
No matter which build template you select, YAML builds remain unaffected.
- Graphical build: Select a build template suitable for your project.
Configuring Build Actions
- Click OK. The Build Actions page is displayed.
- Configure build actions.
- Graphical build: The GUI tab page displays default action set provided by the selected template. You can click the plus sign on a desired build action to add it to your build task. For details about how to configure individual actions, see Configuring Build Actions.
If the preset tool versions do not meet your requirements, you can build an image and push it to SWR by referring to Building an Image and Pushing It to SWR. This allows you to customize an environment for your build.
- YAML build: Click the Code tab page in the upper left corner. The system automatically reads the YAML file from the repository and branch specified in basic information. You may modify the YAML file directly on this page.
Any changes made here will overwrite the original YAML file you prepare once the build task completes.
- Graphical build: The GUI tab page displays default action set provided by the selected template. You can click the plus sign on a desired build action to add it to your build task. For details about how to configure individual actions, see Configuring Build Actions.
- Complete all configurations and click Save to create a build task.
(Optional) Configuring Build Task Parameters
By default, CodeArts Build generates a codeBranch parameter and a set of predefined parameters for each build task. You may adjust the type and value of codeBranch and add custom parameters as needed.
Predefined parameters are automatically generated by the system and can be referenced using the format ${parameter_name}.
To configure parameters:
- Switch to the Parameters tab, and click Create Parameter.
- String: Select String from the Type drop-down list. You can modify the parameter name, type, and value, determine if the parameter is private, and enable runtime settings if required.
- Enumeration: Enter a parameter name and select Enumeration from the Type drop-down list. In the displayed dialog box, enter enumerated values. Each value must end with a semicolon (;). After defining the enumerated values, select a default value from the Default Value drop-down list.
- Auto Increment: Select Auto Increment from the Type drop-down list and specify its value in the Default Value column.
- Use parameters.
- Custom parameters
- Configure a runtime parameter.
Edit the build task. Click the Parameters tab, add a parameter with a custom name and value (for example, set the name to myparam and the default value to 1.0.1.1), and enable Runtime Settings.
- Use the runtime parameter.
Switch to the Build Actions tab and configure a build action. In the Version text box, enter ${myparam}. Save the build task.
- Run the build task.
When you run the build task, a dialog box appears, prompting you to set a parameter value. Enter a custom value or use the predefined default.
- If the task uses Maven and CodeArts Artifact is enabled, you can verify the build result in CodeArts Artifact.
Go to the release repo and find the package produced by the build task. The package version corresponds to the value you define for myparam.
- Configure a runtime parameter.
- Predefined parameters
- Configure a runtime parameter. Edit the build task. Click the Build Actions tab and configure a build action. In the Version text box, enter ${BUILDNUMBER}. Save the build task.
Parameter
Description
BUILDNUMBER
Build ID in the format of "Date.Times that this build task is run on that day. For example: 20200312.3.
TIMESTAMP
Build running timestamp. For example: 20190219191621.
INCREASENUM
A counter representing how many times the task is run. This sequential counter starts at 1 and is incremented by 1 with each run.
PROJECT_ID
Project ID.
WORKSPACE
Workspace. It is the root directory of the source code project.
GIT_TAG
Code tag. This value is set only when the build is triggered from a tagged commit.
COMMIT_ID_SHORTER
First eight characters of the code commit ID.
COMMIT_ID
Code commit ID. For example: b6192120acc67074990127864d3fecaf259b20f5.
- Run the build task.
- If the task uses Maven and CodeArts Artifact is enabled, you can verify the build result in release repos.
Go to the release repo and find the package produced by the build task. The package version corresponds to the value of the system-defined BUILDNUMBER.
- Configure a runtime parameter.
- Custom parameters
(Optional) Scheduling a Build Task
With CodeArts Build, you can configure automated triggers and scheduled tasks to enable continuous integration (CI).
You can configure an execution plan for your build task on the Schedule page.
- Continuous Integration: Enable Run upon Code Commit to trigger a build whenever the referenced code source receives a new commit.
This option is available only when the code source is set to Repo.
- Scheduled Execution: Enable this option and define when and how your build task should run. You can optionally enable Upon Code Change.
After this function is enabled, the build task is run at the specified date and time.
If both Scheduled Execution and Upon Code Change are enabled, the build task executes at the specified date and time only when code has changed since the last build.
(Optional) Configuring Role Permissions for a Build Task
CodeArts Build allows you to configure permissions for each role in a build task. For details about the default user roles and their permissions for the current build task, see Table 3.
| Role | Edit | Delete | View | Execute | Clone | Disable | Assign Permissions |
|---|---|---|---|---|---|---|---|
| Task creator | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) |
| Project creator | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) | √ (*) |
| Project manager | √ | √ | √ | √ | √ | √ | √ |
| Developer | √ | √ | √ | √ | √ | √ | × |
| Test manager | × | × | √ | × | × | × | × |
| Tester | × | × | × | × | × | × | × |
| Participant | × | × | × | × | × | × | × |
| Viewer | × | × | √ | × | × | × | × |
- A check mark (√) indicates that the role has the permission by default, while a cross mark (×) means it does not.
- Roles allowed to assign permissions can edit the permission matrix, except for permissions marked with an asterisk (*), which are fixed and cannot be modified.
- Project creators, project managers, and developers can create build tasks.
You can configure operation permissions for different roles on the Permissions tab page.
Besides, you may click Synchronize Project Permissions to apply the project permissions to the current build task. For details about how to configure project permissions, see Configuring Project-Level Role Permissions.
(Optional) Configuring Notifications for Build Task Events
CodeArts Build provides notifications to help you remain updated on critical build task activities. You can receive notifications whenever a build succeeds or fails, or when a task is disabled, updated, or deleted. These notifications can be delivered through messages or email.
You can manage all notification settings on the Notifications tab.
- Notification/Email: Select Notification or Email to configure each channel separately.
By default, message notifications are sent for all events while emails are only sent for build failures. Use the toggle icons to enable or disable notifications for each event type.
- DingTalk
- Go to the DingTalk group, choose Group Settings > Group Assistant, and add a robot (select Custom).
- Enter the robot name, select a group, and complete the security settings. (Select Additional Signature and click Copy next to the text box to obtain the key.)
- After reading and agreeing to the agreement, click Finished. Click Copy next to the Webhook URL to obtain the DingTalk Webhook URL.
- Select DingTalk, enter a Webhook URL, and click Test to ensure that the Webhook URL is available.
- Select Enable Additional Key, enter the signature key, and select event types.
- Click Save.
After the configuration is complete, CodeArts Build sends task status notifications to the designated DingTalk group whenever specified events occur.
(Optional) Making a Custom Build Task Template
You can save the current build task as a template. The custom template can be selected for later build task creation. The procedure is as follows:
- On the Build History page, click
in the upper right corner and select Make Template from the drop-down list. - Enter the template name and description, and click Save.
- Click the username, and select from the drop-down list.
- In the navigation pane, choose . The saved template is displayed in the list.
You can perform the following operations on saved templates.
Table 4 Managing custom templates Operation
Description
Search for a template
Enter a keyword in the search box to search for a template.
Favorite a template
Click
to add the template to your favorites.Delete a template
Click
. In the displayed dialog box, click Yes to delete the template.
(Optional) Creating a Service Endpoint
When you select any third-party repository on the Basic Information page, the Endpoint is a mandatory setting.
Service endpoints are extensions or plug-ins of CodeArts and provide the capability of connecting to third-party services.
By default, CodeArts Build pull code from CodeArts Repo for build. CodeArts Build also uses service endpoints to connect to third-party repositories to obtain project source code.
- The network may be unstable or other problems may occur when a third-party repository is used.
- Use the code import function of CodeArts Repo for secure, stable, and efficient download and build.
Git
- Click Create next to Endpoint.
- In the displayed dialog box, configure the following parameters.
Parameter
Description
Service Endpoint Name
Name of the service endpoint. It can be customized.
Git Repository URL
URL of the Git repository (HTTPS address).
Username
Username used for logging in to the Git repository.
Password or Access Token
Git repository password or access token.
- Click OK.
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