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

Item.getParams() always returns empty string in pipeline

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Incomplete
    • Icon: Minor Minor
    • core
    • None
    • Jenkins 2.77

      I'm trying to define some parameters in jenkins pipeline, and I can specify the parameters for each build. Then I try to access parameters for items in jenkins Queue, but I always got nothing. Here is my jenkins file:

       

      node {
          // adds job parameters within jenkinsfile
              properties([
                 parameters([
                     booleanParam(
                     defaultValue: false,
                     description: 'isFoo should be false',
                     name: 'isFoo'
                     ),
                     booleanParam(
                     defaultValue: true,
                     description: 'isBar should be true',
                     name: 'isBar'
                   ),
                 ])
               ])
      
          stage("Show items in queue") {
              def q = Jenkins.instance.queue
              echo "There are ${q.items.length} items in queue"
              q.items.each {
                  echo "task ${it.task.name}"
                  echo "${it.params}"
              }
          }
      }

      And output:

       

            Unassigned Unassigned
            liketic Li Ke
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved: