We have been stuck with this problem for a week now though we have been working with pipelines for past few months. Our goal is to spin-up as many containers as many feature files in our cucumber test suite and run those tests in parallel (one per container). Here is the error we are getting with the pipeline code below:
java.lang.UnsupportedOperationException: Calling public static java.util.List org.codehaus.groovy.runtime.DefaultGroovyMethods.each(java.util.List,groovy.lang.Closure) on a CPS-transformed closure is not yet supported (JENKINS-26481); encapsulate in a @NonCPS method, or use Java-style loops
pipeline code:
def cucumberTestImage
pipeline {
agent any
options {
echo "options stuff"
}
stages {
stage('Build & Deploy'){
steps {
parallel (
SPA: {
script {
echo "deploying SPA app"
}
}
}
echo 'SPA JOB COMPLETED!!'
},
Tests: {
script {
}
//building docker image name cucumberTestImage
}
}
)
}
}
stage('Test') {
steps {
script {
def tests = [:]
getFeatures().each {stage -> tests[stage] = {
cucumberTestImage.inside{sh "echo ${stage}"}
}}
parallel tests;
}
}
}
}
}
@NonCPS
def getFeatures() {
return sh(script: 'cd testfolder && find features -type f -name \'*.feature\'', returnStdout: true).tokenize()
}