<p>Got answer from StackOverflow and here is the <a href="https://stackoverflow.com/questions/61702811/it-is-not-allowed-to-use-stages-more-than-once-jenkins-declarative-pipeline">link</a> to the answer.</p>

<pre><code>stage('Test') {
    parallel {
        stage("Test_A") { 
            stages {
                stage("Tests_A") { steps { echo 'from A' } } 
                stage("Archieve") { steps { echo 'from Archieve' } }
            }
        }
        stage("Test_B") {
            ...
        }

        ... and so on
    }
}
</code></pre>

CC BY-SA 4.0
2020-05-10T14:18:14.070Z
2020-05-10T14:18:14.070Z
Auto-learner
<p>I am completely new to the jenkins pipeline. I'm trying to create a project with multiple stages but in my <code>Import</code> stage , I want to execute <code>parallel</code>. For each <code>stage</code> in <code>parallel</code> , I have again multiple <code>stages</code>. I'm trying the following way, but getting syntax error as <code>It is not allowed to use stages more than once</code>.Can someone correct me how to achieve this, I have tried some online resources but unable to get clear syntax.</p>

<pre><code>pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'from build'
      }
    }
  }

    stage('Test_A') {
      parallel {
        stages("GUI") { stage("Tests_A") { steps {echo 'from A'}} stage("Archive") {echo 'from Publish' } }
        stages("API") { stage("Tests_B") {steps {echo 'from B'} } }
        stages("CLI") {  stage("Tests_C") {steps {echo 'from C'} }}

      }
    }

  }
</code></pre>

<p>I want to create something like this</p>

<p><a href="https://i.sstatic.net/aV4iP.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/aV4iP.png" alt="enter image description here"></a></p>

<jenkins-pipeline><build-pipeline><groovy>
It is not allowed to use stages more than once [Jenkins_Declarative_Pipeline]
Auto-learner
# It is not allowed to use stages more than once [Jenkins_Declarative_Pipeline]

(Asked by: username_0 on 2020-05-07)

I am completely new to the jenkins pipeline. I'm trying to create a project with multiple stages but in my Import stage , I want to execute parallel. For each stage in parallel , I have again multiple stages. I'm trying the following way, but getting syntax error as It is not allowed to use stages more than once.Can someone correct me how to achieve this, I have tried some online resources but unable to get clear syntax.
pipeline {
  agent any
  stages {
    stage('Build') {
      steps {
        echo 'from build'
      }
    }
  }

    stage('Test_A') {
      parallel {
        stages("GUI") { stage("Tests_A") { steps {echo 'from A'}} stage("Archive") {echo 'from Publish' } }
        stages("API") { stage("Tests_B") {steps {echo 'from B'} } }
        stages("CLI") {  stage("Tests_C") {steps {echo 'from C'} }}

      }
    }

  }

I want to create something like this

**Tags:** jenkins-pipeline, build-pipeline, groovy


---

## 1 answers

### Answer by username_0 on 2020-05-10. Score: 2

Got answer from StackOverflow and here is the link to the answer.
stage('Test') {
    parallel {
        stage("Test_A") { 
            stages {
                stage("Tests_A") { steps { echo 'from A' } } 
                stage("Archieve") { steps { echo 'from Archieve' } }
            }
        }
        stage("Test_B") {
            ...
        }

        ... and so on
    }
}


---

