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"
}
}
}

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"
}
}
}

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"
}
}
}

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"
}
}
}
}

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
}
}
}

See also

Constructors

Link copied to clipboard
constructor(init: MavenBuildStep.() -> Unit)
constructor()

Types

Link copied to clipboard

Docker image platforms

Link copied to clipboard
Link copied to clipboard

Maven local repository scope.

Properties

Link copied to clipboard

Optional collection of build step execution conditions

Link copied to clipboard
var coverageEngine: <Error class: unknown class>

Specifies coverage engine to use

Link copied to clipboard
var dockerImage: <Error class: unknown class>

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.

Link copied to clipboard
var dockerImagePlatform: <Error class: unknown class>

Specifies which Docker image platform will be used to run this build step.

Link copied to clipboard
var dockerPull: <Error class: unknown class>

If enabled, "pull image" command will be run before docker run.

Link copied to clipboard
var dockerRunParameters: <Error class: unknown class>

Additional docker run command arguments

Link copied to clipboard

Specifies whether the step is enabled, true by default

Link copied to clipboard
Link copied to clipboard
var goals: <Error class: unknown class>

Space-separated list of goals to execute

Link copied to clipboard
var id: String?

Optional id of the step. Usually the id is not required, however if a build configuration inherits from a template and wants to override a build step defined there, then both steps should have the same id.

Link copied to clipboard
var isIncremental: <Error class: unknown class>

Enable incremental building

Link copied to clipboard
var jdkHome: <Error class: unknown class>

A path to JDK to use. By default the JAVA_HOME environment variable or the agent's own Java is used.

Link copied to clipboard
var jvmArgs: <Error class: unknown class>

Space-separated list of additional arguments for JVM

Link copied to clipboard
var localRepoScope: <Error class: unknown class>
Link copied to clipboard
var mavenVersion: <Error class: unknown class>

Maven version to use

Link copied to clipboard

Build step name

Link copied to clipboard
Link copied to clipboard
var pomLocation: <Error class: unknown class>

Path to POM file. Should be relative to the checkout directory.

Link copied to clipboard
var runnerArgs: <Error class: unknown class>

Additional Maven command line parameters.

Link copied to clipboard

Build step type

Link copied to clipboard
var useOwnLocalRepo: <Error class: unknown class>

Use own local artifact repository

Link copied to clipboard
var userSettingsPath: <Error class: unknown class>

The path to a user settings file

Link copied to clipboard
var userSettingsSelection: <Error class: unknown class>

Use one of the predefined settings files or provide a custom path. By default, the standard Maven settings file location is used.

Link copied to clipboard
var workingDir: <Error class: unknown class>

Custom working directory for maven. If not specified, the checkout directory is used.

Functions

Link copied to clipboard

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.

Link copied to clipboard
fun booleanParameter(customName: String? = null, trueValue: String? = "true", falseValue: String? = "false"): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard

Use maven 2 bundled with TeamCity

Link copied to clipboard

Use maven 3.0.5 bundled with TeamCity

Link copied to clipboard

Use maven 3.1.1 bundled with TeamCity

Link copied to clipboard

Use maven 3.2.5 bundled with TeamCity

Link copied to clipboard

Use maven 3.3.9 bundled with TeamCity

Link copied to clipboard

Use maven 3.5.4 bundled with TeamCity

Link copied to clipboard

Use maven 3.6.3 bundled with TeamCity

Link copied to clipboard

Use maven 3.8.6 bundled with TeamCity

Link copied to clipboard

Use maven 3.9.6 bundled with TeamCity

Link copied to clipboard
fun clear()
Link copied to clipboard

Deletes all configured build step conditions

Link copied to clipboard
fun <T : CompoundParam<T>> compoundParameter(customName: String? = null): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard
Link copied to clipboard
fun <T : Parametrized> copyParamsTo(target: T): T

Copies parameters of this object to the specified target

Link copied to clipboard
open fun create(): BuildStep

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.

Link copied to clipboard

The custom Maven version found at the specified path

Link copied to clipboard

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().

Link copied to clipboard

The default Maven version provided by TeamCity server

Link copied to clipboard
fun doubleParameter(customName: String? = null): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard
fun <E : Enum<E>> enumParameter(customName: String? = null, mapping: Map<E, String?>? = null): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard
fun findRawParam(paramName: String): Parameter?
Link copied to clipboard
fun hasParam(paramName: String): Boolean
Link copied to clipboard
Link copied to clipboard
fun intParameter(customName: String? = null): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard
fun param(name: String, value: String)

Adds parameter with specified name and value

Link copied to clipboard
fun removeRawParam(paramName: String)
Link copied to clipboard
open fun stringParameter(customName: String? = null): <Error class: unknown class><Parametrized, <Error class: unknown class><Parametrized, T?>>
Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
open override fun validate(consumer: ErrorConsumer)

Validates this object and reports found errors to the provided consumer