1

Blue ocean pipeline graph

Is it possible that the above two consecutive stages will be in continuous series starting copy server1 stopservers server1 in one line rather than ending for each stage. Do we have a way where copy stopservers will have 4 parallel continuous executions unless like in the image where we have 4 parallel executions for each stage which starts before copy and ends after stopservers.Below is the case which iam looking for
-----------copy--------------stopservers-----------------------
| |
|----------server1-----------server1----------------|
| |
|----------server2-----------server2----------------|
| |
|----------server3----------server3-----------------|
| |
-----------server4----------server4-----------------
and my code is simple and is as below

node { stage('copy'){ parallel 'server1': { echo "server1" }, 'server2': { echo "server2" }, 'server3': { echo "server3" }, 'server4': { echo "server4" } } stage('stopServers'){ parallel 'server1': { echo "server1" }, 'server2': { echo "server2" }, 'server3': { echo "server3" }, 'server4': { echo "server4" } } 

could you please let me know is it possible?

1 Answer 1

1

Sounds like you only need one stage where each of its steps is a compound of a copy step followed by a stopServer step.

def copy(String server) { echo "copy $server" } def stopServer(String server) { echo "stopServer $server" } def servers = [ 'server1', 'server2', 'server3', 'server4' ] node { stage('copy and stopServer') { // Construct the steps to run in parallel def parallelSteps = [:] def i = 0 servers.each { server -> parallelSteps[server] = { // This is just to show that we don't wait for all the copy steps // before we start with stopServer sleep i++ copy(server) stopServer(server) } } parallel parallelSteps } } 
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks towel for your responce. If two stages with compound of a copy step followed by a stopServer step is not possible could you please let me know how to code in jenkins pipeline script to have "one stage where each of its steps is a compound of a copy step followed by a stopServer step" as you said
I added an example to the answer - as you see you can add as many steps as you want for each server.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.