job-dsl allocatePorts does not work

This issue is archived. You can view it, but you can't modify it. Learn more

XMLWordPrintable

      I fail to create a job with an unique TCP port allocated via job-dsl. The following DSL

      freeStyleJob('Test Port Allocation') {
        wrappers {
          allocatePorts 'WEBAPP_HOST_PORT'
        }
      
        steps {
          shell 'env'
        }
      }
      

      generates a Job but the TCP port is missing in the web gui configuration page. When running the generated job no port is allocated.

      The generated config.xml, however, does contain a buildWrappers section about the port:

      <buildWrappers>
      <org.jvnet.hudson.plugins.port__allocator.PortAllocator>
      <ports>
      <org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
      <name>WEBAPP_HOST_PORT</name>
      </org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
      </ports>
      </org.jvnet.hudson.plugins.port__allocator.PortAllocator>
      </buildWrappers>

      Manually configuring the tcp port does work and generates the following buildWrappers block in config.xml

      <buildWrappers>
      <org.jvnet.hudson.plugins.port__allocator.PortAllocator
      plugin="port-allocator@1.8">
      <ports>
      <org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
      <name>WEBAPP_HOST_PORT</name>
      </org.jvnet.hudson.plugins.port__allocator.DefaultPortType>
      </ports>
      </org.jvnet.hudson.plugins.port__allocator.PortAllocator>
      </buildWrappers>

      The only difference I can find, is the plugin attribute of the PortAllocator tag. A tried to match the resulting config.xml with the following DSL but this did not help even though the resulting {{config.xml}}s had identical buildWrappers blocks.

      freeStyleJob('Test Port Allocation') {
        wrappers {
          allocatePorts 'WEBAPP_HOST_PORT'
        }
      
        steps {
          shell 'env'
        }
      
        configure { projectNode ->
          portAllocatorNode = projectNode / buildWrappers / 'org.jvnet.hudson.plugins.port__allocator.PortAllocator'
          portAllocatorNode.@plugin = 'port-allocator@1.8'
        }
      }
      

            Assignee:
            Daniel Spilker
            Reporter:
            Andreas Holzner
            Archiver:
            Jenkins Service Account

              Created:
              Updated:
              Resolved:
              Archived: