We call parallel from a function, it should work, we have similar 
implementation in a step that allows you to pass arrays to parallel to 
build a matrix execution in parallel. The arrays can be static, loaded from 
files, or anything you can convert to an array

https://github.com/elastic/apm-pipeline-library/tree/main/vars#matrix
https://github.com/elastic/apm-pipeline-library/blob/main/vars/matrix.groovy
https://github.com/elastic/apm-pipeline-library/blob/main/vars/axis.groovy


El lunes, 23 de mayo de 2022 a las 22:27:07 UTC+2, chen...@gmail.com 
escribió:

> Hi all, 
>
> I have this piece of code
>
> def s
> def workspace
> pipeline {
>   agent { label 'build_1804' }
>
>   stages {
>     stage('load functions') {
>       steps {
>         script{
>           workspace = env.WORKSPACE
>           node('build_1804') {
>             s = load "${workspace}/regress/Jenkins_extension.groovy"   
>           }
>         }
>       }
>     }
>
>     stage('Build and Test 1') {
>         steps{
>           script{
>             s.buildandtest1(this)
>           }
>         }
>      }
>   }
> }
>
> And other file with:
> def buildandtest1(Object s) {
>   parallel {
>             echo "Building test"
>             echo "Calling test script..."
>             sh """
>               cd regress
>               echo \"./do_standalone_wo_resnet50_2_58.sh\"
>             """
>           }
>         }
>
>     }
> }
>
> Dont put too much attention in {} or other syntax errors, i have modified 
> the code to do it more readable. 
>
> The main problem is that seems that jenkins is not able to start 
> "parallel" stages when it is called from a method. I am getting this error. 
>
> java.lang.IllegalArgumentException: Expected named arguments but got 
> org.jenkinsci.plugins.workflow.cps.CpsClosure2@6a6de064    at 
> org.jenkinsci.plugins.workflow.cps.DSL.singleParam(DSL.java:718)    at 
> org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:706)    at 
> org.jenkinsci.plugins.workflow.cps.DSL.parseArgs(DSL.java:640)    at 
> org.jenkinsci.plugins.workflow.cps.DSL.invokeStep(DSL.java:234)
>
>
> I have googled, but i dont find any solution or clue to fix it.
>
> What am i missing ?
>

-- 
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 jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/0501f3ad-2a94-4ea3-96e7-be76fc6bee2an%40googlegroups.com.

Reply via email to