PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, September 26, 2022

[FIXED] How can I create parallel stages in Jenkins scripted pipeline?

 September 26, 2022     continuous-deployment, continuous-integration, groovy, jenkins-groovy, jenkins-pipeline     No comments   

Issue

I am trying to implement parallelization in my Jenkins pipeline code where I can run two stages in parallel. I know this is possible in declarative pipeline, but I am using scripted pipeline.

I've attempted to implement this by doing something like this:

parallel(
    stage('StageA') {
        echo "This is branch a"
    },
    stage('StageB') {
        echo "This is branch b"
    }
  )

When I run this and look at this in Blue ocean, the stages do not run in parallel, but instead, StageB is executed after StageA. Is it possible to have parallel stages in scripted jenkins pipeline? If so, how?


Solution

Try this syntax for scripted pipeline:

            parallel(
                    "StageA": {
                        echo "This is branch a"
                    },
                    "StageB": {
                        echo "This is branch b"
                    }
            )

It should look like this in Blue Ocean, this is what you expect right?

Parallel blue ocean

If you want to see the stages (and console output) in the classic view, you can use stage like this:

 parallel(
                        "StageA": {
                            stage("stage A") {
                                echo "This is branch a"
                            }
                        },
                        "StageB": {
                            stage("stage B") {
                                echo "This is branch b"
                            }
                        }
                )


Answered By - Unforgettable631
Answer Checked By - Willingham (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing