Jenkins Job Builder / JJB "wrappers" don't have any effect on generated jobs

249 views Asked by At

I'm currently trying to realize job timeouts, etc vi "wrappers" as described in the docs and some examples.

Regardless whether I apply wrappers directly on jobs or on job templates or defaults, I can't see any effect on the generated XML.

There is some bug report from a couple of years ago but despite it sounds quite similar I think the solution does not apply for me since the report is Jenkins specific but my generated config does not contain a <buildWrappers> section at all!

For example the following YAML should generate a timeout section:

- job:
    name: bla
    project-type: "pipeline"
    dsl: |
      sh("hello world")
    wrappers:
      - timeout:
          timeout-var: 'BUILD_TIMEOUT'
          fail: true
          elastic-percentage: 150
          elastic-default-timeout: 90
          type: elastic

Generated output:

<?xml version="1.0" encoding="utf-8"?>
<flow-definition plugin="workflow-job">
  <definition class="org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition" plugin="workflow-cps">
    <script>sh(&quot;hello world&quot;)
</script>
    <sandbox>false</sandbox>
  </definition>
  <actions/>
  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <org.jenkinsci.plugins.workflow.job.properties.DisableConcurrentBuildsJobProperty/>
  </properties>
</flow-definition>

Any idea what I'm doing wrong here?

I'm using jenkins-job-builder v3.12.0 on Python 3.9

1

There are 1 answers

1
frans On

Ok, found it

    def gen_xml(self, xml_parent, data):
        if data.get("project-type", "freestyle") == "pipeline":
            logger.debug("Build wrappers skipped for Pipeline job")
            return

Looks like the documentation just didn't mention that wrappers don't work for the only job type I'm using :)