Jenkins/Hudson job parameters at runtime?

Gogi picture Gogi · Jun 6, 2012 · Viewed 9.3k times · Source

PROBLEM

Let's say I have a jenkins/hudson job (for example free-style) that takes two parameters PARAM_ONE and PARAM_TWO. Now, I do not know the values of those parameters, but I can run some script (perl/shell) to find values of those parameters and then I want the user to select from a dropdown list after which I can start the build.

Is there any way of doing that?

Answer

Jack Leow picture Jack Leow · Jun 6, 2012

Sounds like you've found a plug-in that does what you need, that is pretty similar to the built-in Parameterized Builds functionality.

To answer your second question: when you define parameterized builds, the parameters are typically passed to your job as environment variables. So you'd access them however you access environment variables in your language, for instance, if you defined a parameter PARAM_ONE, you'd access it as:

In bash:

$PARAM_ONE

In Windows batch:

%PARAM_ONE%

In Python:

import os
os.getenv('PARAM_ONE')

etc.

I imagine this would be the same for the Extended Choice Parameter plugin you are using.