Jenkins DSL Pipeline plugin groovy.lang.MissingMethodException: No signature of method: script.pipelineJob()

2.4k views Asked by At

For my local/debug test I have generate xml step. I wan't to add plugin Pipeline Plugin, but I can't figure out which dependency it is, or if I have wrong classpath, or?

my code

 import javaposse.jobdsl.dsl.DslFactory
 import javaposse.jobdsl.dsl.jobs.WorkflowJob

 pipeline = dslFactory.pipelineJob(name)

causes this expception

    Caused by: groovy.lang.MissingMethodException: No signature of method: script.pipelineJob() is applicable for argument types: (java.lang.String) values: [ps-landing-pipeline]

my dependecies (build.gradle)

dependencies {
    compile 'org.codehaus.groovy:groovy:2.1.3'
    compile 'org.jenkins-ci.plugins:job-dsl-core:1.45'
    compile 'org.jenkins-ci.plugins.workflow:workflow-aggregator:2.4'
    testCompile('org.spockframework:spock-core:0.7-groovy-2.0') {
        exclude module: 'groovy-all'
    }
    // for the RestApiScriptRunner and XmlOutputRunner
    compile('ant:ant:1.7.0')
}
1

There are 1 answers

0
Babu On

I found where was the problem, I had bad version of dsl-core

compile 'org.jenkins-ci.plugins:job-dsl-core:1.45'

vs

compile 'org.jenkins-ci.plugins:job-dsl-core:1.47'

-> which version I need I found in API viewer: https://jenkinsci.github.io/job-dsl-plugin/#method/javaposse.jobdsl.dsl.DslFactory.pipelineJob

enter image description here