title: Is it possible to create parallel Jenkins Declarative Pipeline stages in a loop?
body: <p>I have a list of long running Gradle tasks on different sub projects in my project. I would like to run these in parallel using Jenkins declarative pipeline.</p>
  
  <p>I was hoping something like this might work: </p>
  
  <pre class="lang-groovy prettyprint-override"><code>projects = [":a", ":b", ":c"]
  
  pipeline {
      stage("Deploy"){
          parallel {
               for(project in projects){
                 stage(project ) {
                     when {
                         expression {
                              someConditionalFunction(project)
                         }
                     }
                     steps {
                         sh "./gradlew ${project}:someLongrunningGradleTask"
                    }
                  }   
               }
          }
      }
  }
  </code></pre>
  
  <p>Needless to say that gives a compile error since it was expecting stage instead of for. Any ideas on how to overcome this? Thanks</p>