It will be great if this plugin can be used as part of the Workflow plugin by some kind of DSL like:

      def freePort= PortAllocator.get()

          [JENKINS-31449] Port Allocator Pipeline support

          Jesse Glick added a comment -

          PortAllocator would need to become a SimpleBuildWrapper. There are various places AbstractBuild would need to be replaced by Run, and similar minor changes. To survive Jenkins restarts, that means Port must become Serializable, cleanUp needs to be passed in sufficient context that Port need not keep unserializable state, and PortAllocationManager needs to become a persistent Extension (using load/save) with ports keeping only Run.externalizableId and INSTANCES being keyed by Node.name. Pool probably also needs to be come Serializable, enabling PooledPortType to work, and then other types like TomcatShutdownPortType needs to be modified to use static Serializable nested classes for cleanup work. Overall a fairly major refactoring, akin to what I had to do for JENKINS-26477.

          Jesse Glick added a comment - PortAllocator would need to become a SimpleBuildWrapper . There are various places AbstractBuild would need to be replaced by Run , and similar minor changes. To survive Jenkins restarts, that means Port must become Serializable , cleanUp needs to be passed in sufficient context that Port need not keep unserializable state, and PortAllocationManager needs to become a persistent Extension (using load / save ) with ports keeping only Run.externalizableId and INSTANCES being keyed by Node.name . Pool probably also needs to be come Serializable , enabling PooledPortType to work, and then other types like TomcatShutdownPortType needs to be modified to use static Serializable nested classes for cleanup work. Overall a fairly major refactoring, akin to what I had to do for JENKINS-26477 .

          Code changed in jenkins
          User: Jesse Glick
          Path:
          COMPATIBILITY.md
          http://jenkins-ci.org/commit/workflow-plugin/384ef03deb67580c1e3b99fd6551b39b21bc40b8
          Log:
          JENKINS-31449 Noting.

          SCM/JIRA link daemon added a comment - Code changed in jenkins User: Jesse Glick Path: COMPATIBILITY.md http://jenkins-ci.org/commit/workflow-plugin/384ef03deb67580c1e3b99fd6551b39b21bc40b8 Log: JENKINS-31449 Noting.

          Jens Mittag added a comment - - edited

          Hi together. I have worked on this issue and now you can use it inside of a pipeline. Have a look at my fork at https://github.com/m00re/port-allocator-plugin

          Usage:
          wrap([$class: 'PortAllocator', pool: 'POOLNAME']) {
          }

          So far, I only added support for Pooled Ports (from within the pipeline), but the required changes to support other port types should be marginal. The changes also make sure that you can mix between classic job descriptions and pipeline projects.

          What is not yet working: surviving Jenkins restarts. For us/me, this is not a requirement, but I am willing to add support for this too if someone provides me the necessary pointers (I already tried, but as this was my first Jenkins plugin work, my knowledge of Jenkins plugin interna is very limited).

          Jens Mittag added a comment - - edited Hi together. I have worked on this issue and now you can use it inside of a pipeline. Have a look at my fork at https://github.com/m00re/port-allocator-plugin Usage: wrap( [$class: 'PortAllocator', pool: 'POOLNAME'] ) { } So far, I only added support for Pooled Ports (from within the pipeline), but the required changes to support other port types should be marginal. The changes also make sure that you can mix between classic job descriptions and pipeline projects. What is not yet working: surviving Jenkins restarts. For us/me, this is not a requirement, but I am willing to add support for this too if someone provides me the necessary pointers (I already tried, but as this was my first Jenkins plugin work, my knowledge of Jenkins plugin interna is very limited).

          Eh, I'm trying to figure out how to use this too right now. I'm not even able to install your fork by myself. I've found this http://stackoverflow.com/questions/14950408/how-to-install-a-plugin-in-jenkins-manually but I couldn't manage to get an hpi out of your fork. (I should probably put more time at trying to setup mvn correctly.

          And what do you mean by "What is not yet working: surviving Jenkins restarts."?

          Any plans to merge this upstream?

          Gabriel Le Breton added a comment - Eh, I'm trying to figure out how to use this too right now. I'm not even able to install your fork by myself. I've found this http://stackoverflow.com/questions/14950408/how-to-install-a-plugin-in-jenkins-manually but I couldn't manage to get an hpi out of your fork. (I should probably put more time at trying to setup mvn correctly. And what do you mean by "What is not yet working: surviving Jenkins restarts."? Any plans to merge this upstream?

          Jesse Glick added a comment -

          if someone provides me the necessary pointers

          As in my original comment, anything referred to by the Disposer needs to be Serializable. Otherwise in

          wrap([$class: 'PortAllocator', pool: 'POOLNAME']) {
            sh 'make world' // runs five hours, restart Jenkins after two
          }
          

          the build will explode after the restart.

          Jesse Glick added a comment - if someone provides me the necessary pointers As in my original comment, anything referred to by the Disposer needs to be Serializable . Otherwise in wrap([$class: 'PortAllocator' , pool: 'POOLNAME' ]) { sh 'make world' // runs five hours, restart Jenkins after two } the build will explode after the restart.

          jbq added a comment -

          FYI implementation has been submitted as part of https://github.com/jenkinsci/port-allocator-plugin/pull/10

          I just used it successfully in my project, any active maintainer could review it and integrate the changes?

          jbq added a comment - FYI implementation has been submitted as part of https://github.com/jenkinsci/port-allocator-plugin/pull/10 I just used it successfully in my project, any active maintainer could review it and integrate the changes?

          James Howe added a comment -

          olivergondza oldelvet

          Are either of you able to sort this out?
          I'm not sure if the PR needs updating e.g. for declarative support.

          James Howe added a comment - olivergondza oldelvet Are either of you able to sort this out? I'm not sure if the PR needs updating e.g. for declarative support.

          There is a pull request proposed that needs more work. As the plugin appears generally unmaintained, it takes a volunteer to have a look at that..

          Oliver Gondža added a comment - There is a pull request proposed that needs more work. As the plugin appears generally unmaintained, it takes a volunteer to have a look at that..

          Andrea Knight added a comment -

          Hello, has there been any more progress on this item?

          Andrea Knight added a comment - Hello, has there been any more progress on this item?

            jbq jbq
            lielran Liel Ran
            Votes:
            20 Vote for this issue
            Watchers:
            24 Start watching this issue

              Created:
              Updated: