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 {
        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'
          }
        )
      }
    }
  }
}


On Wednesday, August 23, 2017 at 9:40:32 PM UTC-4, jothibasu k wrote:
>
> 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.
>
> https://stackoverflow.com/questions/44585619/parallel-jenkins-pipeline
>
>
> https://stackoverflow.com/questions/45294813/jenkins-declarative-pipeline-parallel-stages
>
> Thanks,
> JB
>
> On Thursday, August 24, 2017 at 6:53:07 AM UTC+5:30, jothibasu k wrote:
>>
>> 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,
>>
>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Jenkins Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to jenkinsci-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/3ff93e0d-e44b-41f1-a72c-25d43c7f532d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to