1

I have a job configured in jenkins, that has 4-5 choice parameter. Till now we used to do "build with parameter"-> select one of the parameters and run the job.

Now a new requirement has come, where, the same job has to be triggered with each of these parameters one by one.

I am quite new to jenkins, and could not find exact solution for this requirement. Looking for some help here.

Thanks.

  • It does not look straight forward though, you can try to have one job with all the parameters and trigger another job by passing each parameter. ref: https://stackoverflow.com/questions/9704677/jenkins-passing-variables-between-jobs .. https://stackoverflow.com/questions/10810975/1-jenkins-job-trigger-multiple-jenkins-jobs-based-on-parameters – greengreyblue Nov 05 '18 at 12:54
  • I used script posted by Gripsiden. Thanks for your help. – Chandan Sinha Nov 08 '18 at 12:18

1 Answers1

1

You could use Pipeline to trigger ?

node{
 try{
      stage('1st Parameter') 
{
  build job: 'target_job_name_here', parameters: 
      [
      string(name: 'parameter_1', value: 'Parameter1-value')
      ]
}
 }    
   catch (err){
      echo "1st Parameter fail"
   }
 try{
      stage('2nd Parameter') 
{
  build job: 'target_job_name_here', parameters: 
      [
      string(name: 'parameter_2', value: 'Parameter2-value')
      ]
}
 }    
   catch (err){
      echo "2nd Parameter fail"
   }
 try{
      stage('3rd Parameter') 
{
  build job: 'target_job_name_here', parameters: 
      [
      string(name: 'parameter_3', value: 'Parameter3-value')
      ]
}
 }    
   catch (err){
      echo "3rd Parameter fail"
   }

}

Not sure if that would help?

Gripsiden
  • 467
  • 2
  • 15
  • I followed you suggestion, and used name variable same for all the three calls.: string(name: 'Value_Env', value: 'Parameter1-value') string(name: 'Value_Env', value: 'Parameter2-value') Created parameter in downstream job and used Value_Env as value of that. It worked fine. Thanks a lot. – Chandan Sinha Nov 08 '18 at 12:12
  • No problem , enjoy! – Gripsiden Nov 14 '18 at 11:19