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

Need way to clear/reset allocated xvnc ports - groovy?

    • Icon: Task Task
    • Resolution: Unresolved
    • Icon: Minor Minor
    • xvnc-plugin
    • None

      See here:

      http://stackoverflow.com/questions/31481107/jenkins-xvnc-plugin-some-display-numbers-stay-allocated-when-a-build-is-stopped

      I'm having the same issue. I can probably get this done during a scheduled outage on the jenkins master, but that's really invasive. Is there any way to call a function via groovy to reset and clear the content?

          [JENKINS-40496] Need way to clear/reset allocated xvnc ports - groovy?

          Stijn D added a comment -

          This is a groovy script I created to clean up the Xvnc display numbers without stopping jenkins. But it might also clean up numbers of still running jobs.

          https://github.com/sdiepend/jenkins-monitoring/blob/master/cleanXvncDisplayNumbers.groovy

          import jenkins.*
          import jenkins.model.Jenkins
          
          
          Jenkins jenkins = Jenkins.getActiveInstance();
          xvncDescriptor = jenkins.getDescriptorByType(hudson.plugins.xvnc.Xvnc.DescriptorImpl.class)
          
          
          xvncDescriptor.allocators.each {
            allocator = it.value
            // collect is used to make sure numAlloc is an entire new list and not just a reference to the same list object, otherwise you'll get a
            // concurrentmodification exception
            numAlloc = allocator.allocatedNumbers.collect()
          
          
            numAlloc.each {
              allocator.allocatedNumbers.remove(it)
            }
          }

          Stijn D added a comment - This is a groovy script I created to clean up the Xvnc display numbers without stopping jenkins. But it might also clean up numbers of still running jobs. https://github.com/sdiepend/jenkins-monitoring/blob/master/cleanXvncDisplayNumbers.groovy import jenkins.* import jenkins.model.Jenkins Jenkins jenkins = Jenkins.getActiveInstance(); xvncDescriptor = jenkins.getDescriptorByType(hudson.plugins.xvnc.Xvnc.DescriptorImpl.class) xvncDescriptor.allocators.each { allocator = it.value // collect is used to make sure numAlloc is an entire new list and not just a reference to the same list object, otherwise you'll get a // concurrentmodification exception numAlloc = allocator.allocatedNumbers.collect() numAlloc.each { allocator.allocatedNumbers.remove(it) } }

            levsa Levon Saldamli
            nneul Nathan Neulinger
            Votes:
            3 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: