Chandan Sinha
Chandan Sinha

Reputation: 33

How to run job with each parameter jenkins

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.

Upvotes: 1

Views: 711

Answers (1)

Gripsiden
Gripsiden

Reputation: 497

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?

Upvotes: 1

Related Questions