Skip to content
This repository has been archived by the owner on Sep 25, 2024. It is now read-only.

Latest commit

 

History

History
157 lines (118 loc) · 5.25 KB

defaultCompileStage.md

File metadata and controls

157 lines (118 loc) · 5.25 KB

defaultCompileStage

The default compile stage executes maven with clean deploy -B -U and (of course) the default defines and settings provided by the pipeline (ManagedFiles) auto lookup mechanism

and the arg

Table of contents

Step sequence

Get default maven defines

This step calls the getDefaultMavenDefines step first to enable defines like

  • -Dcontinuous-integration=true or
  • -Dnodejs.directory=${WORKSPACE}/target/.nodejs (when a nodejs package.json was found in the project)

Configuration merge

The step then merges the default defines and the maven defaults with the incoming configuration.

Execute Maven

After the configuration merge the execMaven step is called with the configuration

Recording fingerprints

After the maven execution the fingerprints of the artifacts are recorded. Used pattern: **/target/**/*.jar,**/target/**/*.zip

Stashing workspace files

If enabled the step will stash the current workspace files under the name compileFiles so you will be able to use these files later in your build on another node.

💡 The files will be then available by using unstash the name compileFiles (ConfigConstants.STASH_COMPILE_FILES).

Extension options

This step supports the extension mechanism, so you are able to extend the step by executing code before and/or after the step is executed or even replacing the whole functionality.

💡 See _extend for an example.

Configuration options

All configuration options must be inside the compile (ConfigConstants.STAGE_COMPILE) map element to be evaluated and used by the step.

import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*
defaultCompileStage(
    (STAGE_COMPILE) : [
        (MAVEN) : [
            // config from execMaven step
        ],
        (STAGE_COMPILE_EXTEND) : null,
        (STASH) : false
    ]
)

_extend (optional)

Constant ConfigConstants.STAGE_COMPILE_EXTEND
Type Closure with signature (Map config, superImpl)
Default null

Use this configuration option to overwrite or extend the defaultCompileStage step.

Example:

import static de.provision.devops.jenkins.pipeline.utils.ConfigConstants.*
import static io.wcm.devops.jenkins.pipeline.utils.ConfigConstants.*

def customCompileStage(Map config, superImpl) {
  echo "before defaultCompileStage stage"
  superImpl(config)
  echo "after defaultCompileStage stage"
}

defaultCompileStage(
  (STAGE_COMPILE) : [
    (STAGE_COMPILE_EXTEND) : this.&customCompileStage
  ]
)

maven (optional)

Constant ConfigConstants.MAVEN
Type Map
Default null

Since the configuration is calculated inside the step the default would be

[
    (MAVEN_GOALS) : ["clean", "deploy"],
    (MAVEN_ARGUMENTS) : ["-B", "-U"],
    (MAVEN_DEFINES) : ["continuous-integration" : true]
]

💡 Please have a look at execMaven for a complete list of configuration options.

💡 When running in buildFeature then the goals are clean install per default.

stash (optional)

Constant ConfigConstants.STASH
Type Boolean
Default false

Controls if the workspace files will be stashed after the maven build.

💡 Use the available constant from ConfigConstants

Related classes