Maven Build Step
A build step running maven
Example. Adds a simple Maven build step in the checkout directory and pom.xml located in the checkout directory. Default bundled maven tool is used, JDK from JAVA_HOME environment variable is used.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
maven {
name = "Install step"
goals = "clean install"
}
Content copied to clipboard }
}
Example. Adds a Maven build step with custom path to project root and pom.xml. Extra maven command line argumant is specified. Custom bundled maven version is specified. JDK is set to the environment variable value.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
maven {
goals = "clean install"
pomLocation = "intergation-tests/pom.xml"
runnerArgs = "-X"
workingDir = "intergation-tests"
mavenVersion = bundled_3_9()
userSettingsSelection = "settings.xml"
jdkHome = "%env.JDK_11_0_x64%"
jvmArgs = "-Xmx2048m"
}
Content copied to clipboard }
}
Example. Adds a Maven build step with customized path to maven executable and JDK. Custom Maven settings provided on project level are set. This build step will run even if some previous build steps are failed.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
maven {
executionMode = BuildStep.ExecutionMode.RUN_ON_FAILURE
goals = "clean install"
mavenVersion = custom {
path = "my/own/mvn"
}
userSettingsSelection = "settings.xml"
jdkHome = "/path/to/java/home"
}
Content copied to clipboard }
}
Example. Adds a Maven build step with Maven executable taken from M2_HOME environment variable, otherwise the current default version is used. Incremental Building is enabled, and local artifact repository settings is set to use a separate repository to store artifacts, produced by all builds of the current build configuration. IDEA-based code coverage is enabled.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
maven {
goals = "clean install"
mavenVersion = auto()
localRepoScope = MavenBuildStep.RepositoryScope.BUILD_CONFIGURATION
isIncremental = true
coverageEngine = idea {
includeClasses = """
org.myorg.*
org.package.sample
""".trimIndent()
excludeClasses = "org.myorg.test"
}
}
Content copied to clipboard }
}
Example. Adds a Maven build step to be run inside a Docker container. This step will we executed only if build status is sucessfull for previous build steps and extra condition is met.
buildType {
// Other Build Type settings ...
steps {
// Other Build Steps ...
maven {
executionMode = BuildStep.ExecutionMode.RUN_ON_SUCCESS
conditions {
equals("teamcity.build.branch", "release")
}
goals = "clean install"
mavenVersion = auto()
dockerImage = "dockerImage"
dockerImagePlatform = MavenBuildStep.ImagePlatform.Linux
dockerPull = true
}
Content copied to clipboard }
}
See also
Types
Properties
Optional collection of build step execution conditions
Specifies coverage engine to use
Specifies which Docker image to use for running this build step. I.e. the build step will be run inside specified docker image, using 'docker run' wrapper.
Specifies which Docker image platform will be used to run this build step.
If enabled, "pull image" command will be run before docker run.
Additional docker run command arguments
Build step execution mode
Enable incremental building
Maven version to use
Path to POM file. Should be relative to the checkout directory.
Additional Maven command line parameters.
Use own local artifact repository
The path to a user settings file
Use one of the predefined settings files or provide a custom path. By default, the standard Maven settings file location is used.
Custom working directory for maven. If not specified, the checkout directory is used.
Functions
Maven version specified by the M2_HOME environment variable. If the environment variable is empty, then the default Maven version provided by TeamCity server will be used.
Use maven 2 bundled with TeamCity
Use maven 3.0.5 bundled with TeamCity
Use maven 3.1.1 bundled with TeamCity
Use maven 3.2.5 bundled with TeamCity
Use maven 3.3.9 bundled with TeamCity
Use maven 3.5.4 bundled with TeamCity
Use maven 3.6.3 bundled with TeamCity
Use maven 3.8.6 bundled with TeamCity
Use maven 3.9.6 bundled with TeamCity
Deletes all configured build step conditions
Configures build step conditions
Copies parameters of this object to the specified target
The custom Maven version found at the specified path
In TeamCity 10.0 the meaning of this option was: Maven version specified in M2_HOME environment variable, if the environment variable is empty, then the Maven version 3.0.5. In TeamCity 2017.1 this option is renamed to auto(), please use it instead. If you want to always use the default Maven version provided by TeamCity server, switch to defaultProvidedVersion().
The default Maven version provided by TeamCity server
Validates this object and reports found errors to the provided consumer