> 16 jun 2015 kl. 02:08 skrev CLOSE Dave <[email protected]>:
> 
> I wrote:
> 
>> I have a Jenkins job using the build flow plugin. A portion of it
>> looks like the code below.
>> 
>> parallel (
>>   { ignore ( FAILURE ) { build ( "job1", BRANCH: params [ "BRANCH" ] ) } },
>>   { ignore ( FAILURE ) { build ( "job2", BRANCH: params [ "BRANCH" ] ) } }
>> )
>> 
>> I'd like to replace the BRANCH parameter with a call to a script so
>> that I can use a fallback branch in some cases. Doing so seems fairly
>> tricky but I think I got it working, sort of. The code now looks like
>> this.
>> 
>> branchName = build.buildVariableResolver.resolve("BRANCH")
>> def chkbranch ( String product, String branch ) {
>>   def cmd = ["/bin/bash", "-c", "/home/jenkins/bin/chkbranch"+"
>> "+product+" "+branch]  // Build the command string to run
>>   def ans = cmd.execute().text  // Run the command
>>   return "$ans"[0..-2]  // Chomp the answer before returning
>> }
>> parallel (
>>   { ignore ( FAILURE ) { build ( "job1", BRANCH: chkbranch ( "job1", 
>> branchName ) ) } }
>>   { ignore ( FAILURE ) { build ( "job2", BRANCH: chkbranch ( "job2", 
>> branchName ) ) } }
>> )
>> 
>> But this doesn't work. It throws a completely indecipherable Groovy
>> error and I'm lost. But it does work if I remove the "parallel"
>> grouping. Unfortunately, that extends the time to run the job
>> excessively.
>> 
>> The error looks something like the following. Any ideas?
>> 
>> ERROR: Failed to run DSL Script
>> groovy.lang.MissingMethodException: No signature of method:
>> Script1$_run_closure8.call() is applicable for argument types:
>> (Script1$_run_closure9, Script1$_run_closure10, Script1$_run_closure11,
>> Script1$_run_closure12, Script1$_run_closure13, Script1$_run_closure14,
>> Script1$_run_closure15) values: [Script1$_run_closure9@9202ce0,
>> Script1$_run_closure10@1f622ace, ...]
>> Possible solutions: doCall(), any(), any(), find(), grep(), dump()
>>    at 
>> org.codehaus.groovy.runtime.metaclass.ClosureMetaClass.invokeMethod(ClosureMetaClass.java:264)
>>    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:903)
>>    at groovy.lang.MetaClassImpl.invokeMethod(MetaClassImpl.java:723)
>>    at 
>> groovy.lang.GroovyObjectSupport.invokeMethod(GroovyObjectSupport.java:44)
>>    at 
>> org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45)
>>    at 
>> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
>>    at 
>> org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108)
>>    at Script1.run(Script1.groovy:30)
>>    at Script1$run.call(Unknown Source)
>>    at 
>> org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42)
>>    at Script1$run.call(Unknown Source)
>>    at com.cloudbees.plugins.flow.FlowDSL.executeFlowScript(FlowDSL.groovy:84)
>>    at 
>> com.cloudbees.plugins.flow.FlowRun$FlyweightTaskRunnerImpl.run(FlowRun.java:219)
>>    at hudson.model.Run.execute(Run.java:1759)
>>    at com.cloudbees.plugins.flow.FlowRun.run(FlowRun.java:155)
>>    at hudson.model.ResourceController.execute(ResourceController.java:89)
>>    at hudson.model.Executor.run(Executor.java:240)
>>    at hudson.model.OneOffExecutor.run(OneOffExecutor.java:43)
> 
> Stefan Thomasson answered:
> 
>> I am not sure that this is what cause the error but I think you
>> forgot a comma between the two ignores
> 
> Thanks for the reply. But that was just a cut-and-paste error. I don't 
> actually have the version quoted as the parallel statements are 
> commented in my copy. Without the parallel, the commas should not be 
> present. When I removed the comments to include the code in my message, 
> I forgot to put the commas back.
> 
> I'm still stymied by the obtuse Groovy error and hoping for some 
> enlightenment.
> 

This will probably not help you, but I  tried your example, and it worked.

Buildflow 0.17+0.18, jenkins 1,610 on windows

//st

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/453593A1-EE88-4FEF-84B4-F64E14AE130A%40gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to