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

[PrioritySorter] not work when start builds quickly, for example parallel start builds

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Critical Critical
    • prioritysorter-plugin
    • Jenkins: 2.479.1
      OS: Linux - 3.10.0-1160.el7.x86_64
      Java: 17.0.13 - Eclipse Adoptium (OpenJDK 64-Bit Server VM)
      ---
      PrioritySorter:5.2.0

      1.Job Priorities set : Use additional rules when assigning a priority to a job --> Use Priority from Build Parameter Build Parameter Name[PriorityBuild] . not set other rules

      2.create job test_priority with parameter -PriorityBuild,pipeline script code:

       

      pipeline {
          agent {
              label "heping_test_label"
          }
          stages {
              stage('A') {
                  steps {
                      script {
                           def entryTime = new Date().format('HH:mm:ss')
                           // currentBuild.displayName += " priority: ${env.PriorityBuild} entryTime: ${entryTime}"
                           currentBuild.description = "entryTime: ${entryTime}, priority: ${env.PriorityBuild}, throttle: ${env.ThrottleCategory}"
                           // sleep time: 1, unit: 'MINUTES'
                           sleep 30
                      }
                  }
              }
          }
      } 

       

      3. create job upstream,pipeline script code:

       pipeline {
          agent none 
          stages {
              stage('upstream') {
                  steps {
                      script {
                          def params_list = ["1", "2", "3", "4", "5", "1", "2", "3", "4", "5", "1", "2", "3", "4", "5"]
                          def branch = [:]
                          def i = 0
                          params_list.each { param ->
                              def currentParam = param 
                              def currentI = i        
                              branch["${currentI}"] = {
                                  def test_set_list = []
                                  test_set_list.add([$class: 'StringParameterValue', name: "PriorityBuild", value: currentParam])
                                  test_set_list.add([$class: 'StringParameterValue', name: "UniqueID", value: UUID.randomUUID().toString()])
                                  build job: 'test_priority', parameters: test_set_list, wait: true
                              }
                              i++
                          }
                          parallel branch
                      }
                  }
              }
          }
      }

      result:when job upstream parallel start test_priotity, or upstream start buils one by one very quickly,priority not work, the builds all get priority 5

      log:

      Sorted 13 hudson.model.Queue$BuildableItems with Min Weight 5 and Max Weight 5
      Apr 16, 2025 2:46:55 PM FINER PrioritySorter.Queue.Sorterhudson.model.Queue$BuildableItem Queue:
      +----------------------------------------------------------------------+
      |   Item Id  |        Job Name       | Priority |        Weight        |
      +----------------------------------------------------------------------+
      |        938 | part of t...rity #456 |        5 |              5.00000 |
      |        939 | part of t...rity #451 |        5 |              5.00000 |
      |        940 | part of t...rity #461 |        5 |              5.00000 |
      |        941 | part of t...rity #458 |        5 |              5.00000 |
      |        942 | part of t...rity #464 |        5 |              5.00000 |
      |        943 | part of t...rity #457 |        5 |              5.00000 |
      |        944 | part of t...rity #462 |        5 |              5.00000 |
      |        945 | part of t...rity #452 |        5 |              5.00000 |
      |        946 | part of t...rity #463 |        5 |              5.00000 |
      |        947 | part of t...rity #465 |        5 |              5.00000 |
      |        948 | part of t...rity #453 |        5 |              5.00000 |
      |        949 | part of t...rity #455 |        5 |              5.00000 |
      |        950 | part of t...rity #460 |        5 |              5.00000 |
      +----------------------------------------------------------------------+ 

      4.job upstream change pipeline script code:

      pipeline {
          agent none
          stages {
              stage('upstream') {
                  steps {
                      script {
                          def params_list = ["1", "2", "3", "4", "5", "1", "2", "3", "4", "5", "1", "2", "3", "4", "5"]
                          def i = 0
                          params_list.each { param ->
                              def currentParam = param
                              def currentI = i       
                              def test_set_list = []
                              test_set_list.add([$class: 'StringParameterValue', name: "PriorityBuild", value: currentParam])
                              test_set_list.add([$class: 'StringParameterValue', name: "UniqueID", value: UUID.randomUUID().toString()])
                              build job: 'test_priority', parameters: test_set_list, wait: false
                              sleep 10
                              i++
                          }
                      }
                  }
              }
          }
      } 

      result: when the builds start one by one every 10 seconds,or rebuild any build,priority is correct

      logger:

      Sorted 2 hudson.model.Queue$BuildableItems with Min Weight 2 and Max Weight 5
      Apr 16, 2025 3:41:30 PM FINER PrioritySorter.Queue.Sorterhudson.model.Queue$BuildableItem Queue:
      +----------------------------------------------------------------------+
      |   Item Id  |        Job Name       | Priority |        Weight        |
      +----------------------------------------------------------------------+
      |        965 | part of t...rity #472 |        2 |              2.00000 |
      |        961 | part of t...rity #470 |        5 |              5.00000 |
      +----------------------------------------------------------------------+ 

            Unassigned Unassigned
            alyson alyson
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: