mavenJob('check-bom-dependencies') {
description 'Job checking the BOM dependencies'
label('maven3')
logRotator {
numToKeep 3
}
parameters {
globalVariableParam('reportFileName', 'dependency-tree.txt', 'Report file name containing the putput of the dependency tree')
stringParam('TAG', '2.3.4.Final',
'The release version for the artifact. If you leave this empty, ' +
'the current SNAPSHOT version will be used with the ' +
'"-SNAPSHOT" suffix removed (example: if the current version ' +
'is "1.0-SNAPSHOT", the release version will be "1.0").')
}
scm {
git {
remote {
branch '$TAG'
}
}
}
preBuildSteps {
steps {
systemGroovyCommand '''\
import jenkins.model.Jenkins
println "Backup the pom.xml file"
def jenkins = Jenkins.getInstanceOrNull()
//get job Item
def item = jenkins.getItemByFullName("check-bom-dependencies")
println item
java.lang.IllegalStateException: steps cannot be applied for Maven jobs
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)