We are getting the below error with parallel pipeline for the 'Test' Stage which essentially tries to spin-up docker containers equal to number of tests for parallel execution. Will appreciate any thoughts/suggestions to fix this.
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()
}