How to get a parameter depend of other parameter in Hudson or Jenkins

前端 未结 5 759
天涯浪人
天涯浪人 2020-12-15 08:08

I have a problems with Hudson because my job needs two params for build the first specifies the environment and can be one of DEV, QA, PROD, and the second is a specific ser

相关标签:
5条回答
  • 2020-12-15 08:51

    Try Active Choices Plugin. It is the second name of Uno-Choice plugin, but it is located in official Jenkins repository and does not require UpdateSites Manager plugin. (Both plugins have the same author). Plugin has a great documentation with examples (and gif-demonstration) on the plugin's description page.

    0 讨论(0)
  • 2020-12-15 08:51

    You can try the EnvInject Plugin.

    First you put the first parameter into a settings file.Then the plugin can read from the file .Step two,generate the second parameter with your own script.

    0 讨论(0)
  • 2020-12-15 08:52

    I ran into similar problems. I have a parameter for the environment Dev1, Dev2, ..... and a second one for the server where I need to run the job. I can compute the second from the first, but then the job is already running and I can't move it to another server anymore.

    So I ended up having the two parameters with all possible choices and teaching the users to only choose the valid combinations. I can test during script execution whether the combination is valid. I also put a small html table in the comment of one of the parameters which contains valid combinations.

    In your case, can you compute the value of the first parameter from the values of the second parameters? Then you would be able to compute (if still necessary) the value of the first parameter, write it to a temporary properties file and load it with the EnvInject plugin in a later build step.

    0 讨论(0)
  • 2020-12-15 09:11

    It appears that Jenkins loads the list of parameters to select when you open the "build project" page. There's no callback happening when selecting a parameter either.

    In that case it will be difficult to restrict the second parameter based on the first one without javascript and a custom plugin.

    I also looked at those:

    • https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+plugin
    • https://wiki.jenkins-ci.org/display/JENKINS/Extended+Choice+Parameter+Script+plugin
    • https://wiki.jenkins-ci.org/display/JENKINS/Extensible+Choice+Parameter+plugin

    I would ask the jenkins user list for more information.

    0 讨论(0)
  • 2020-12-15 09:11

    A good plugin (requires you to have the UpdateSites Manager plugin and register the biouno update site) is the uno-choice plugin ( and friends).

    The Uno-Choice Cascade Dynamic Parameter Plugin plugin allows for not only more than two levels of dependencies, but can generate dynamic content for the parameters which depend on previous input using either scriptler or inline groovy.

    This is certainly much more capable than the previous answers.

    0 讨论(0)
提交回复
热议问题