MavenBuildStep
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_8()
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
Constructors
Types
Docker image platforms
Maven local repository scope.
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
Deletes all configured build step conditions
Configures build step conditions
Copies parameters of this object to the specified target
Creates an instance of this build step via reflection using a no argument constructor, used during copying. Throws an error if this class doesn't have a default constructor. Subclasses can override it to create an instance without using a default constructor.
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
Properties
If enabled, "pull image" command will be run before docker run.