Updated on 2024-11-21 GMT+08:00

Using a Custom Build Environment

If the tool version supported by CodeArts Build does not meet your requirements, you can use a custom image that has been uploaded to SWR.

Setting the Image Type to Public

Private images in SWR cannot be pulled by CodeArts Build during the build process. Therefore, you need to set the image type to Public before starting the build.

  1. Log in to SWR.
  2. In the navigation pane, choose My Images, click the image name to go to the image details page, and click Edit in the upper right corner.
  3. In the displayed dialog box, set Type to Public and click OK.
    Figure 1 Editing an image
  4. To obtain the complete image path, click to copy the image download command. The part following docker pull is the image path.

Build on GUI

Add Use SWR Public Image when configuring build actions step. Set the parameters according to Table 1.

Table 1 Parameters for using an SWR public image

Parameter

Description

Action Name

Assign a custom name to the build action. The name can contain:

  • Letters, digits, hyphens (-), underscores (_), commas (,), semicolons (;), colons (:), periods (.), slashes (/), and parentheses.
  • 1 to 128 characters.

Image Address

Enter the image path obtained in 4.

Commands

Configure commands, or use the default ones. If you have special build requirements, enter your custom build script in the text box.

For example, if the image is used for a Maven build, configure commands for building with Maven. For an npm build, configure commands for building with npm. This rule also applies to other builds.

Continue After Failure

Specify whether to proceed after the current action fails by setting the parameter to either Yes or No.

Build with Code

Modify the code in the BUILD block in Creating a YAML File for Your Code-based Build by referring to the following sample code:

1
2
3
4
5
6
7
8
version: 2.0 # The value must be 2.0.
steps:
  BUILD:
    - swr:
       image: cloudbuild@ddd
       inputs:
          command: echo 'hello'
          ignore_fail: true
Table 2 Parameters in the sample code for using an SWR image

Parameter

Type

Description

image

String

Set the image path in either of the following ways:
  • Use an address that starts with cloudbuild and uses the tag sign (@) as a separator, with the tool version supported by CodeArts Build following it. For example, cloudbuild@maven3.5.3-jdk8-open, where maven3.5.3-jdk8-open is the version of Maven being used.
  • Use the image path obtained in 4.

command

String

Configure the command.

For example, if the image is used for a Maven build, configure commands for building with Maven. For an npm build, configure commands for building with npm. This rule also applies to other builds.

ignore_fail

String

Whether to proceed after the current action fails.
  • true: Yes
  • Empty: No