Skip to content



This step runs a maven command based on the parameters provided to the step.


name mandatory default possible values
defines No
dockerEnvVars No []
dockerImage No maven:3.6-jdk-8
dockerName No mvn
dockerOptions No []
dockerPullImage No false
dockerWorkspace No \<empty>
flags No
globalSettingsFile No
goals Yes
logSuccessfulMavenTransfers No false true, false
m2Path No
pomPath No
projectSettingsFile No
returnStdout No false true, false
script Yes
verbose No false true, false
  • defines: Additional properties in form of -Dkey=value.
  • dockerEnvVars: Environment variables to set in the container, e.g. [http_proxy: "proxy:8080"].
  • dockerImage: Name of the docker image that should be used. If empty, Docker is not used and the command is executed directly on the Jenkins system.
  • dockerName: Kubernetes only: Name of the container launching dockerImage. SideCar only: Name of the container in local network.
  • dockerOptions: Docker options to be set when starting the container.
  • dockerPullImage: Set this to 'false' to bypass a docker image pull. Usefull during development process. Allows testing of images which are available in the local registry only.
  • dockerWorkspace: Kubernetes only: Specifies a dedicated user home directory for the container which will be passed as value for environment variable HOME.
  • flags: Flags to provide when running mvn.
  • globalSettingsFile: Path to the mvn settings file that should be used as global settings file.
  • goals: Maven goals that should be executed.
  • logSuccessfulMavenTransfers: Configures maven to log successful downloads. This is set to false by default to reduce the noise in build logs.
  • m2Path: Path to the location of the local repository that should be used.
  • pomPath: Path to the pom file that should be used.
  • projectSettingsFile: Path to the mvn settings file that should be used as project settings file.
  • returnStdout: Returns the output of the maven command for further processing.
  • script: The common script environment of the Jenkinsfile running. Typically the reference to the script calling the pipeline step is provided with the this parameter, as in script: this. This allows the function to access the commonPipelineEnvironment for retrieving, e.g. configuration parameters.
  • verbose: verbose output

Breaking change in goals, defines and flags parameters

The goals, defines and flags parameters of the step need to be lists of strings with each element being one item.

As an example consider this diff, showing the old api deleted and the new api inserted:

-goals: 'org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate',
-defines: "-Dexpression=$pomPathExpression -DforceStdout -q",
+goals: ['org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate'],
+defines: ["-Dexpression=$pomPathExpression", "-DforceStdout", "-q"],

Additionally please note that in the parameters must not be shell quoted/escaped. What you pass in is literally passed to Maven without any shell interpreter inbetween.

The old behavior is still available in version v1.23.0 and before of project "Piper".

Step Configuration

We recommend to define values of step parameters via config.yml file.

In following sections of the config.yml the configuration is possible:

parameter general step/stage
dockerEnvVars X
dockerImage X
dockerName X
dockerOptions X
dockerPullImage X
dockerWorkspace X
flags X
globalSettingsFile X X
logSuccessfulMavenTransfers X X
m2Path X X
pomPath X
projectSettingsFile X X
verbose X




mavenExecute script: this, goals: ['clean', 'install']

Example for the correct usage of goals, defines and flags in version v1.24.0 and newer:

    script: script,
    goals: ['org.apache.maven.plugins:maven-help-plugin:3.1.0:evaluate'],
    defines: ["-Dexpression=$pomPathExpression", "-DforceStdout", "-q"],
    returnStdout: true

Note that it does not work to put multiple arguments into one element of a list, so defines: ["-Dexpression=$pomPathExpression -DforceStdout -q"] does not work.