hudsonjenkinshudson-pluginsjenkins-plugins

Jenkins/Hudson job parameters at runtime?


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?


Solution

  • 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.