ExpediaGroup / jenkins-spock

Unit-test Jenkins pipeline code with Spock
https://javadoc.io/doc/com.homeaway.devtools.jenkins/jenkins-spock
Apache License 2.0
186 stars 73 forks source link

Parallel stages in declarative pipeline 1.2 #119

Open balza opened 2 years ago

balza commented 2 years ago

Desired Behavior

I like to test a declarative pipeline

stage('Build Application') {
  failFast true
  parallel {
      stage('Create Docker Image') {
          environment {
              ECR_REPOSITORY_URL = "${GlobalVariables.ECR_REGISTRY}"
              AWS_DEFAULT_REGION = "${GlobalVariables.AWS_REGION}"
              TARGET_IMAGE = params.BUILD_TARGET_IMAGE.toLowerCase()
          }
          steps {
              script {
                  buildDocker.buildStage(env.IMAGE_TAG)
                  quality.scanECRVulnerabilities()
              }
          }
      }

      stage('SonarQube analysis [maven]') {
          agent {
              label BUILD_MAVEN_SLAVE_NAME
          }
          steps {
              script {
                  quality.sonarQubeMaven()
              }
          }
      }
  }
}

when I try to test it I get

groovy.lang.MissingMethodException: No signature of method: com.homeaway.devtools.jenkins.testing.JenkinsPipelineSpecification$_addPipelineMocksToObjects_closure1$_closure14$_closure16.doCall() is applicable for argument types: (buildDockerMaven$_call_closure1$_closure4$_closure11$_closure26) values: [buildDockerMaven$_call_closure1$_closure4$_closure11$_closure26@47fa3671] Possible solutions: doCall(java.util.Map), findAll(), findAll(), isCase(java.lang.Object), isCase(java.lang.Object)

I saw https://github.com/ExpediaGroup/jenkins-spock/pull/55/ but from what I read https://www.jenkins.io/blog/2017/09/25/declarative-1/ hey say is an old standard

Is there a way to easily test this kind of parallel pipelines?

Thanks