Skip to content

mavenBuild

This step will install the maven project into the local maven repository.

Description

This step will install the maven project into the local maven repository. It will also prepare jacoco to record the code coverage and supports ci friendly versioning by flattening the pom before installing.

build with depedencies from a private repository

if your build has dependencies from a private repository you can include a project settings xml into the source code repository as below (replace the <url> tag with a valid private repo url).

<?xml version="1.0" encoding="UTF-8"?>
<settings xmlns="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 https://maven.apache.org/xsd/settings-1.0.0.xsd">
  <servers>
    <server>
        <id>private.repo.id</id>
        <username>${env.PIPER_VAULTCREDENTIAL_USERNAME}</username>
        <password>${env.PIPER_VAULTCREDENTIAL_PASSWORD}</password>
    </server>
  </servers>
</settings>
PIPER_VAULTCREDENTIAL_USERNAME and PIPER_VAULTCREDENTIAL_PASSWORD are the username and password for the private repository and are exposed as environment variables that must be present in the environment where the Piper step runs or alternatively can be created using : vault general purpose credentials

include the below <repositories> tag in your pom.xml to reference the <server> and make sure the values in the <id> tags match

<repositories>
    <repository>
      <id>private.repo.id</id>
      <url>https://private.repo.com/</url>
    </repository>
</repositories>

Ensure the following configuration in the Piper config.yaml to ensure the above settings xml is included and all steps can consume this parameter:

general:
  projectSettingsFile: <path to the above settings.xml>

Usage

We recommend to define values of step parameters via .pipeline/config.yml file.
In this case, calling the step is essentially reduced to defining the step name.
Calling the step can be done either in an orchestrator specific way (e.g. via a Jenkins library step) or on the command line.

library('piper-lib-os')

mavenBuild script: this
piper mavenBuild

Outputs

Output type Details
commonPipelineEnvironment
  • custom/buildSettingsInfo

Parameters

Overview - Step

Name Mandatory Additional information
script (yes) Jenkins only reference to Jenkins main pipeline script
altDeploymentRepositoryID no
altDeploymentRepositoryPassword no Vault Secret pass via ENV, Vault or Jenkins credentials (altDeploymentRepositoryPasswordId)
altDeploymentRepositoryUrl no
altDeploymentRepositoryUser no
buildSettingsInfo no
createBOM no
customTlsCertificateLinks no
deployFlags no
flatten no
globalSettingsFile no
javaCaCertFilePath no
logSuccessfulMavenTransfers no
m2Path no
pomPath no
profiles no
projectSettingsFile no
publish no
verbose no activates debug output
verify no

Overview - Execution Environment

Orchestrator-specific only

These parameters are relevant for orchestrator usage and not considered when using the command line option.

Name Mandatory Additional information
containerCommand no Jenkins only
containerShell no Jenkins only
dockerEnvVars no
dockerImage no
dockerName no
dockerOptions no
dockerPullImage no
dockerVolumeBind no Jenkins only
dockerWorkspace no Jenkins only
stashContent no Jenkins only

Details

altDeploymentRepositoryID

Id for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in ). This id will be updated in settings.xml and will be used as a flag with DaltDeploymentRepository along with mavenAltDeploymentRepositoryUrl during maven deploy . When no settings.xml is provided a new one is created corresponding with tag

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_altDeploymentRepositoryID (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/repositoryId

altDeploymentRepositoryPassword

Password for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in ). This password will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with tag

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_altDeploymentRepositoryPassword (if set)
Secret yes
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/mavenRepositoryPassword
commonPipelineEnvironment:
  reference to: custom/repositoryPassword
Jenkins credential id:
  id: altDeploymentRepositoryPasswordId

Vault paths:
  • $(vaultPath)/alt-deployment-repository-passowrd
  • $(vaultBasePath)/$(vaultPipelineName)/alt-deployment-repository-passowrd
  • $(vaultBasePath)/GROUP-SECRETS/alt-deployment-repository-passowrd

altDeploymentRepositoryUrl

Url for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in ). This Url will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with tag

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_altDeploymentRepositoryUrl (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/mavenRepositoryURL
commonPipelineEnvironment:
  reference to: custom/repositoryUrl

altDeploymentRepositoryUser

User for the alternative deployment repository to which the project artifacts should be deployed ( other than those specified in ). This user will be updated in settings.xml . When no settings.xml is provided a new one is created corresponding with tag

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_altDeploymentRepositoryUser (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/mavenRepositoryUsername
commonPipelineEnvironment:
  reference to: custom/repositoryUsername

buildSettingsInfo

build settings info is typically filled by the step automatically to create information about the build settings that were used during the maven build . This information is typically used for compliance related processes.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default $PIPER_buildSettingsInfo (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/buildSettingsInfo

containerCommand

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Allows to specify start command for container created with dockerImage parameter to overwrite Piper default (/usr/bin/tail -f /dev/null).

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

containerShell

Jenkins-specific: Used for proper environment setup.

Allows to specify the shell to be executed for container with containerName.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

createBOM

Creates the bill of materials (BOM) using CycloneDX Maven plugin.

back to overview

Scope Details
Aliases maven/createBOM
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

List of download links to custom TLS certificates. This is required to ensure trusted connections to instances with repositories (like nexus) when publish flag is set to true.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default $PIPER_customTlsCertificateLinks (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

deployFlags

maven deploy flags that will be used when publish is detected.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default - -Dmaven.main.skip=true
- -Dmaven.test.skip=true
- -Dmaven.install.skip=true
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerEnvVars

Jenkins-specific: Used for proper environment setup.

Environment variables to set in the container, e.g. [http_proxy: "proxy:8080"].

back to overview

Scope Details
Aliases -
Type map[string]string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerImage

Jenkins-specific: Used for proper environment setup.

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.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default maven:3.6-jdk-8
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerName

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Name of the container launching dockerImage. SideCar only: Name of the container in local network.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default mvn
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerOptions

Jenkins-specific: Used for proper environment setup.

Docker options to be set when starting the container.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerPullImage

Jenkins-specific: Used for proper environment setup.

Set this to 'false' to bypass a docker image pull. Useful during development process. Allows testing of images which are available in the local registry only.

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default true
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerVolumeBind

Jenkins-specific: Used for proper environment setup.

Volumes that should be mounted into the docker container.

back to overview

Scope Details
Aliases -
Type map[string]string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

dockerWorkspace

Jenkins-specific: Used for proper environment setup.

Kubernetes only: Specifies a dedicated user home directory for the container which will be passed as value for environment variable HOME.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

flatten

Defines if the pom files should be flattened to support ci friendly maven versioning.

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default true
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☐ stages
Resource references none

globalSettingsFile

Path to the mvn settings file that should be used as global settings file.

back to overview

Scope Details
Aliases maven/globalSettingsFile
Type string
Mandatory no
Default $PIPER_globalSettingsFile (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references commonPipelineEnvironment:
  reference to: custom/mavenGlobalSettingsFile

javaCaCertFilePath

path to the cacerts file used by Java. When maven publish is set to True and customTlsCertificateLinks (to deploy the artifact to a repository with a self signed cert) are provided to trust the self signed certs, Piper will extend the existing Java cacerts to include the new self signed certs. if not provided Piper will search for the cacerts in $JAVA_HOME/jre/lib/security/cacerts

back to overview

Scope Details
Aliases maven/javaCaCertFilePath
Type string
Mandatory no
Default $PIPER_javaCaCertFilePath (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

logSuccessfulMavenTransfers

Configures maven to log successful downloads. This is set to false by default to reduce the noise in build logs.

back to overview

Scope Details
Aliases maven/logSuccessfulMavenTransfers
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

m2Path

Path to the location of the local repository that should be used.

back to overview

Scope Details
Aliases maven/m2Path
Type string
Mandatory no
Default $PIPER_m2Path (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

pomPath

Path to the pom file which should be installed including all children.

back to overview

Scope Details
Aliases -
Type string
Mandatory no
Default pom.xml
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

profiles

Defines list of maven build profiles to be used.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default $PIPER_profiles (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

projectSettingsFile

Path to the mvn settings file that should be used as project settings file.

back to overview

Scope Details
Aliases maven/projectSettingsFile
Type string
Mandatory no
Default $PIPER_projectSettingsFile (if set)
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

publish

Configures maven to run the deploy plugin to publish artifacts to a repository.

back to overview

Scope Details
Aliases maven/publish
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☒ steps
  • ☒ stages
Resource references none

script

Jenkins-specific: Used for proper environment setup.

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.

back to overview

Scope Details
Aliases -
Type Jenkins Script
Mandatory yes
Default
Secret no
Configuration scope
  • ☐ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references none

stashContent

Jenkins-specific: Used for proper environment setup.

Specific stashes that should be considered for the step execution.

back to overview

Scope Details
Aliases -
Type []string
Mandatory no
Default - ``
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

verbose

verbose output

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages
Resource references none

verify

Instead of installing the artifact only the verify lifecycle phase is executed.

back to overview

Scope Details
Aliases -
Type bool
Mandatory no
Default false
Possible values - true
- false
Secret no
Configuration scope
  • ☒ parameter
  • ☐ general
  • ☐ steps
  • ☐ stages
Resource references none

altDeploymentRepositoryPasswordId

Jenkins-specific: Used for proper environment setup. See using credentials for details.

Jenkins credentials ID containing the artifact deployment repository password.

back to overview

Scope Details
Aliases -
Type string
Configuration scope
  • ☒ parameter
  • ☒ general
  • ☒ steps
  • ☒ stages