Step is not supported with preStepBuilds and MavenJob

12 views
Skip to first unread message

Charles Moulliard

unread,
Dec 11, 2020, 11:01:21 AM12/11/20
to job-dsl-plugin
Hi

The following syntax does not work

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 {
                url 'https://github.com/snowdrop/spring-boot-bom'
                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
              
as when the job runs, we got as error

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)

What is the workaround ?

Regards

Charles

Matt Sheehan

unread,
Dec 11, 2020, 11:18:05 AM12/11/20
to job-dsl-plugin
It looks like systemGroovyCommand should be directly under preBuildSteps rather than within a steps block. 


--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/bd25c89a-73c9-4c04-bbb0-c6478f03a86en%40googlegroups.com.

Charles Moulliard

unread,
Dec 11, 2020, 11:22:03 AM12/11/20
to job-dsl-plugin
Correct. That works better doing that 

   preBuildSteps {
            systemGroovyCommand '''\
              import jenkins.model.Jenkins

              println "Backup the pom.xml file"
              def jenkins = Jenkins.getInstanceOrNull()

Reply all
Reply to author
Forward
0 new messages