Link to home
Start Free TrialLog in
Avatar of simon3270
simon3270Flag for United Kingdom of Great Britain and Northern Ireland

asked on

Jenkins throws missing method exception when one job calls another job

I'm running Jenkins 2.277.1, and trying to get one job to call another.

The main job (written using DSL), creates a list of identifiers (in this case, of clusters we want to shut down). It then tries to call a "shutdown a cluster" job for each of those clusters.


The call to start the jobs is in groovy. The "ssm_list" variable contains a list of items, with the cluster name and manifest name separated by an underscore (this was inherited code!). The bare bones of the script are as follows. I've tried changing the parameter types so that they match the ones in the job being called (e.g. the "listGitBranches"), or generic (e.g.. "string"), but no combinations seem to work. I've also tried wrapping the call in "wrap([$class: 'BuildUser']) {", and wrapping the job in parentheses ("build(job:...)". The "cluster-shutdown-branch" job is in the same directory on the Jenkins server as the calling one. The job has many more parameters than I am providing, but the rest all have useful default values.  I have the "Pipeline: Build Step" plugin v2.15 installed. 

        stage ('Run shutdown job based on the list'){
            agent none
            steps {
                script {
                    ssm_list.each {
                        def split_vars = it.split('_')
                        echo "Shutting down ${split_vars[0]}"
                            build job: 'cluster-shutdown-branch', parameters: [string(name: 'CLUSTER_NAME', value: split_vars[0], listGitBranches(name: 'MANIFEST_BRANCH', value: split_vars[1])
                    }
                }
            }
        }



Open in new window

The error I get starts:

hudson.remoting.ProxyException: groovy.lang.MissingMethodException: No signature of method: build.call() is applicable for argument types: (java.util.LinkedHashMap) values: [[job:cluster-shutdown-cmp-branch, parameters:[@string(name=CLUSTER_NAME,value=din-6453h), ...], ...]]
Possible solutions: wait(), any(), wait(long), main([Ljava.lang.String;), any(groovy.lang.Closure), each(groovy.lang.Closure)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:58)
   at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:64)
   at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:54)
   at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:48)
   at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:113)
   at org.kohsuke.groovy.sandbox.impl.Checker$1.call(Checker.java:163)
   at org.kohsuke.groovy.sandbox.GroovyInterceptor.onMethodCall(GroovyInterceptor.java:23)
   at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:158)
   at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onMethodCall(SandboxInterceptor.java:143)

Open in new window

Any suggestions of where I should look for the problem?

Avatar of krakatoa
krakatoa
Flag of United Kingdom of Great Britain and Northern Ireland image

Please post any - preferably all - Java code involved in your problem space.
Avatar of simon3270

ASKER

I have no java code, I'm just writing Jenkins DSL and Groovy code. All of the java is in Jenkins (a.k.a Hudson) code.
ASKER CERTIFIED SOLUTION
Avatar of simon3270
simon3270
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial