Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62536

fetch source values from jenkins extended choice parameter

    Details

    • Similar Issues:

      Description

      I have added an extended choice paramter. Now the source values are lin1, lin2, lin3 as listed in screenshot

      now when I run, If I select lin1 then I get param3 = lin1,

      If I select lin1 and lin2 then I get param2 - lin1,lin2 ( delimiter is comma )

      The question here is, inside jenkins pipeline how can get what all source values were set when the param was created. In short, without selecting any of the checkboxes, want to get the list of the possible values probably in a list

      Eg: list1 = some_method(param3) // expected output >> list1 = [lin,lin2,lin3]

      Let me know if this description is not clear.

        Attachments

          Activity

          Hide
          azee77 Abhijeet Zope added a comment - - edited

           

          Solution: 

          import hudson.model.*
          import org.jenkinsci.plugins.workflow.job.*

          def job = getJob(JOB_NAME)
          def allWindows = getParam(job, "Windows").getValue()
          // allWindows will have all the source values

          def getJob(name)

          { def hi = Hudson.instance return hi.getItemByFullName(name, Job) }

          def getParam(WorkflowJob job, String paramName) {
          def prop = job.getProperty(ParametersDefinitionProperty.class)
          for (param in prop.getParameterDefinitions()) {
          if (param.name == paramName)

          { return param }

          }
          return null
          }

          Show
          azee77 Abhijeet Zope added a comment - - edited   Solution:  import hudson.model.* import org.jenkinsci.plugins.workflow.job.* def job = getJob(JOB_NAME) def allWindows = getParam(job, "Windows").getValue() // allWindows will have all the source values def getJob(name) { def hi = Hudson.instance return hi.getItemByFullName(name, Job) } def getParam(WorkflowJob job, String paramName) { def prop = job.getProperty(ParametersDefinitionProperty.class) for (param in prop.getParameterDefinitions()) { if (param.name == paramName) { return param } } return null }

            People

            • Assignee:
              azee77 Abhijeet Zope
              Reporter:
              azee77 Abhijeet Zope
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: