Call parallel stages from a loaded file

974 views
Skip to first unread message

chencho m-a

unread,
May 23, 2022, 4:27:07 PM5/23/22
to Jenkins Users
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 ?

Ivan Fernandez Calvo

unread,
May 24, 2022, 12:52:17 PM5/24/22
to Jenkins Users
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

chencho

unread,
May 25, 2022, 2:34:05 AM5/25/22
to jenkins...@googlegroups.com
Thank you, Ivan. I will try with matrix

Gracias ;)

--
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-use...@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 all
Reply to author
Forward
0 new messages