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

Latest commit

 

History

History
156 lines (121 loc) · 5.92 KB

defaultAnalyzeStage.md

File metadata and controls

156 lines (121 loc) · 5.92 KB

defaultAnalyzeStage

The default analyze stage executes maven with static analysis goals for

  • checkstyle
  • pmd
  • findbugs

and (of course) witg the default defines and settings provided by the pipeline (ManagedFiles) auto lookup mechanism.

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

Stashing workspace files

If enabled the step will stash the current workspace files under the name analyzeFiles 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 analyzeFiles (ConfigConstants.STASH_ANALYZE_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 analyze (ConfigConstants.STAGE_ANALYZE) 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.*
defaultAnalyzeStage(
  (STAGE_ANALYZE) : [
    (MAVEN) : [
        // config from execMaven step
    ],
    (STAGE_ANALYZE_ENABLED) : true,
    (STAGE_ANALYZE_EXTEND) : null,
    (STASH) : false
  ]
)

enabled (optional)

Constant ConfigConstants.STAGE_ANALYZE_ENABLED
Type Boolean
Default true

Use this configuration option to enable (default) or disable the defaultAnalyzeStage step.

_extend (optional)

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

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

Example:

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

def customAnalyzeStage(Map config, superImpl) {
  echo "before defaultAnalyzeStage stage"
  superImpl(config)
  echo "after defaultAnalyzeStage stage"
}

defaultAnalyzeStage(
  (STAGE_ANALYZE) : [
    (STAGE_ANALYZE_EXTEND) : this.&customAnalyzeStage
  ]
)

maven (optional)

Constant ConfigConstants.MAVEN
Type Map
Default null

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

[
    (MAVEN_GOALS) : "checkstyle:checkstyle pmd:pmd spotbugs:spotbugs",
    (MAVEN_ARGUMENTS) : "-B",
    (MAVEN_DEFINES) : ["continuous-integration" : true]
]

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

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