Search code examples
jenkinsjenkins-plugins

Conditional Parameter based on User input in Jenkins


I have a requirement to call a parameter based on user input for another parameter. In short,

I have a parameter for build_type with choice values Daily, Release and Snapshot. Only whenever user selects Snapshot option for build_type, it should prompt user to enter snapshot name.

Do we have any plugin for this ?

Thanks, Ras.


Solution

  • Give this a try https://wiki.jenkins.io/pages/viewpage.action?pageId=74875956
    Its straight forward you can also try this https://wiki.jenkins.io/display/JENKINS/Extended+Choice+Parameter+plugin

    EDITED
    It does work, you just have to do a bit of groovy scripting :)

    First you need to select Active Choice Parameter enter image description here

    Then select Active Choice Reactive reference Parameter

    enter image description here

    Groovy script

       if(States.equals("Snapshot")){
    inputBox="<input name='Snapshot' type='text' >"
    }
    

    TA-DA enter image description here

    I'll leave the beautification/formatting to you :)