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.
This step calls the
getDefaultMavenDefines
step first to enable
defines like
-Dcontinuous-integration=true
or-Dnodejs.directory=${WORKSPACE}/target/.nodejs
(when a nodejspackage.json
was found in the project)
The step then merges the default defines and the maven defaults with the incoming configuration.
After the configuration merge the
execMaven
step is called with the configuration
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
).
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.
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
]
)
Constant | ConfigConstants.STAGE_ANALYZE_ENABLED |
Type | Boolean |
Default | true |
Use this configuration option to enable (default) or disable the
defaultAnalyzeStage
step.
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
]
)
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.
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
)