How can I create parameterized Jenkins job?

Sreevalsa E picture Sreevalsa E · Aug 5, 2015 · Viewed 29.8k times · Source

I want to use same job in different machine. But I don't want to change the configuration of the job each time. Can I pass the machine name label as parameter and run the job in different machine ? (Not simultaneously).

I want to pass parameters while running a job to the script which I have written in th configuration (batch script). Can we do that ?

Can I get a return value from a job and use it in next job?

Answer

Vitalii Elenhaupt picture Vitalii Elenhaupt · Aug 5, 2015
  1. Yes, you can pass a node label parameter with NodeLabel Parameter Plugin.

  2. Yes, you can define parameters, as described, in Parameterized Builds and then use it in your script as an environment variable:

The parameter is available as environment parameters. So e.g. a shell ($FOO, %FOO%) or Ant ( ${env.FOO} ) can access these values.

  1. This is not exactly a return value, but you can pass any parameter (with its value) to the downstream job with Parameterized Trigger Plugin.