Updated on 2026-01-08 GMT+08:00

Building with Maven

Graphical Build

Add Build with Maven, when configuring build actions.

The parameters are described in the following table.

Parameter

Description

Action Name

Assign a custom name to the build action.

Tool Version

Select a tool version.

Commands

Configure Maven commands. You can also use default commands.

setting File Configuration

  • The setting file is automatically generated with repositories. The optimal repository access mode is automatically configured based on the user's IP address, which may be in regions in or outside the current country. You are advised to retain the default settings.
  • Public repositories: By default, open-source mirrors are added, and SDK repositories have been configured. This configuration is used only when you need to add a public repository that is not provided by CodeArts. The procedure is as follows:
    1. Click Add.
    2. Enter the repository address, and select Release and Snapshot as required. Select either Release or Snapshot, or both.

      Release: If this option is selected, the build process attempts to download the release version dependency from the repository.

      Snapshot: If this option is selected, the build process attempts to download the snapshot version dependency from the repository.

  • Private repositories: By default, self-hosted repos provided by CodeArts have been configured. This configuration is used only when you need to add other private repository. The procedure is as follows:
    1. Click Add, select the service endpoint created in the previous step, and select Release and Snapshot as required.
NOTE:

Release and Snapshot are two types of repositories. Pay attention to their differences. If you upload a dependency to a release repository, it cannot be downloaded during a build.

  • Snapshot: For private dependency packages released for debugging, add the -SNAPSHOT suffix to the dependency version (for example, 1.0.0-SNAPSHOT). During each release, the dependency is automatically released to the snapshot repository. The version does not need to be updated each time the dependency is released. You can add the -U parameter to the build command to obtain the latest version.
  • For officially released private dependency packages, do not add the -SNAPSHOT suffix to the dependency version (for example, 1.0.0). During each release, the dependency is automatically released to the release repository. The version must be updated each time the dependency is released. Otherwise, the latest dependency package cannot be obtained during the build.

Release to Self-hosted Repos

By default, CodeArts Build uses the self-hosted repos as the download source of private dependency. The configuration is required for uploading build products to the self-hosted repos and store the build products as dependencies for other projects. Before the configuration, . The configuration procedure is as follows:

  • Do not configure POM: Private dependencies do not need to be released to the self-hosted repo.
  • Configure all POMs: Deployment configurations are added to all pom.xml files of the project. The mvn deploy command is used to upload the built dependency package to a self-hosted repo of CodeArts Artifact.

    In the command window, use # to comment out the mvn package -Dmaven.test.skip=true -U -e -X -B command.

    Delete # before the #mvn deploy -Dmaven.test.skip=true -U -e -X -B command.

The uploaded private dependency can be referenced by adding the groupId, artifactId, and version coordinates in the pom.xml file to other projects.

Unit Test

To process unit test results, set the parameters. For details, see Configuring a Unit Test.

Cache

Opt to use the cache to improve the build speed. If you set Use Dependency Cache to Yes, the downloaded dependency package is cached during each build. In this way, the dependency package does not need to be pulled repeatedly during subsequent builds, which effectively improves the build speed.

NOTE:

After the dependency package built by Maven is stored in the cache, the cache directory is updated only when a new dependency package is introduced to the project built by the tenant. The existing dependency package cache file cannot be updated.

Code-based Build

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
version: 2.0 # The value must be 2.0.
steps:
  BUILD:
    - maven:
          image: cloudbuild@maven3.5.3-jdk8-open # You can customize the image path.
          inputs:
            settings:
              public_repos:
                - https://mirrors.example.com/maven
            cache: true # Indicates whether to enable the cache.
            unit_test:
              coverage: true
              ignore_errors: false
              report_path: "**/TEST*.xml"
              enable: true
              coverage_report_path: "**/site/jacoco"
            command: mvn package -Dmaven.test.failure.ignore=true -U -e -X -B

Parameter

Type

Description

Mandatory

Default Value

image

String

The image address can be in any of the following formats:

  • cloudbuild@maven3.5.3-jdk8-open, which starts with cloudbuild, uses @ as the separator, and is followed by the default image provided by CodeArts Build.
  • Complete SWR image path, for example, swr.example.example.com/codeci_test/demo:141d26c455abd6d7xxxxxxxxxxxxxxxxxxxx.

Yes

None

settings

Map

Setting for Maven builds.

No

None

cache

Bool

Whether to enable cache.

No

false

command

String

Commands to be run.

Yes

None

unit_test

Map

Unit test.

No

None

Parameters for unit_test are described in the following table.

Parameter

Type

Description

Mandatory

Default Value

enable

Bool

Whether to process test data.

No

true

ignore_errors

Bool

Whether to ignore unit test errors.

No

true

report_path

String

Unit test data path.

Yes

None

coverage

Bool

Whether to process coverage data.

No

false

coverage_report_path

String

Coverage data path.

No

None