Jenkins pipeline parallel execution for different nodes on both Declarative and Scripted

2,698 views
Skip to first unread message

jothibasu k

unread,
Aug 23, 2017, 9:23:07 PM8/23/17
to Jenkins Users
I understand the basic difference between the Declarative and scripted pipeline in Jenkins 2.0.

when I try to implement the parallel deployment on different nodes, it seems declarative is not working I guess.

Question
========
1. can you please confirm running the parallel task in the different node is supported or not in both pipeline model.
2. if it works the syntax to do that in the declarative and scripted pipeline.

My declarative pipeline 

pipeline {
agent any
stages {
stage('build') {
  agent { label 'testnode' }
  echo 'build process'
}
stage('Deployment') {
steps {
parallel (
"Deployment1": {
agent { label 'server01'}
echo 'deployment in server1'
},

"Deployment2": {
agent { label 'server02 }
echo 'deployment in server2'
}
)
}
}
}
}

the above example is not working, if i put the agent in stage level it is working but stream level it is not working, basically, i like to understand parallel execution in the different node is supported or not on both pipelines.

Thanks in Advance,


jothibasu k

unread,
Aug 23, 2017, 9:40:32 PM8/23/17
to Jenkins Users
I like to add stackoverflow questions also, in the below two questions in one they are saying it doable in Declarative and another saying you need to wrap it with script {} block.

which one i we need to follow.


JB

Kevin Burnett

unread,
Aug 25, 2017, 12:17:54 PM8/25/17
to Jenkins Users
you can use the "parallel" step in a declarative pipeline. you cannot wrap multiple stages inside a parallel step unless you use scripted (currently. this may be implemented in declarative in the future).

it is very hard to read code that is not indented. please indent your code. :) i think this is your pipeline, but with "steps" added inside the build stage and with a quote added to the end of the label 'server02' (it now validates clean):

pipeline {
  agent any
  stages {
    stage('build') {
      steps {
Reply all
Reply to author
Forward
0 new messages