ktdreyer/jenkins-job-wrecker

Does not parse build-timeout as a wrapper

Closed this issue · 3 comments

version: jenkins-job-wrecker-1.4.3
input:

<?xml version='1.0' encoding='UTF-8'?>
<project>
  <actions/>
  <description>&lt;!-- Managed by Jenkins Job Builder --&gt;&lt;!-- Managed by Jenkins Job Builder --&gt;</description>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>-1</daysToKeep>
        <numToKeep>25</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.25">
      <autoRebuild>false</autoRebuild>
      <rebuildDisabled>false</rebuildDisabled>
    </com.sonyericsson.rebuild.RebuildSettings>
    <hudson.model.ParametersDefinitionProperty>
      <parameterDefinitions>
        <hudson.model.StringParameterDefinition>
          <name>PIPELINE_DIR</name>
          <description></description>
          <defaultValue>/tmp</defaultValue>
        </hudson.model.StringParameterDefinition>
      </parameterDefinitions>
    </hudson.model.ParametersDefinitionProperty>
  </properties>
  <scm class="hudson.scm.NullSCM"/>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <authToken>cdoqa_token</authToken>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <builders>
    <hudson.tasks.Shell>
      <command>#!/bin/bash -eux
echo four&#xd;</command>
    </hudson.tasks.Shell>
  </builders>
  <publishers>
    <hudson.plugins.postbuildtask.PostbuildTask plugin="postbuild-task@1.8">
      <tasks>
        <hudson.plugins.postbuildtask.TaskProperties>
          <logTexts>
            <hudson.plugins.postbuildtask.LogProperties>
              <logText></logText>
              <operator>OR</operator>
            </hudson.plugins.postbuildtask.LogProperties>
          </logTexts>
          <EscalateStatus>false</EscalateStatus>
          <RunIfJobSuccessful>false</RunIfJobSuccessful>
          <script>#!/bin/bash&#xd;
echo test&#xd;</script>
        </hudson.plugins.postbuildtask.TaskProperties>
      </tasks>
    </hudson.plugins.postbuildtask.PostbuildTask>
  </publishers>
  <buildWrappers>
    <hudson.plugins.build__timeout.BuildTimeoutWrapper plugin="build-timeout@1.18">
      <strategy class="hudson.plugins.build_timeout.impl.AbsoluteTimeOutStrategy">
        <timeoutMinutes>5</timeoutMinutes>
      </strategy>
      <operationList>
        <hudson.plugins.build__timeout.operations.FailOperation/>
      </operationList>
    </hudson.plugins.build__timeout.BuildTimeoutWrapper>
  </buildWrappers>
</project>

command:
jjwrecker -f test.xml -n test

output:

- job:
    auth-token: cdoqa_token
    block-downstream: false
    block-upstream: false
    builders:
    - shell: |-
        #!/bin/bash -eux
        echo four
    concurrent: false
    description: <!-- Managed by Jenkins Job Builder --><!-- Managed by Jenkins Job
      Builder -->
    disabled: false
    name: !!python/unicode 'test'
    parameters:
    - string:
        default: /tmp
        description: ''
        name: PIPELINE_DIR
    project-type: freestyle
    properties:
    - build-discarder:
        artifact-days-to-keep: -1
        artifact-num-to-keep: -1
        days-to-keep: -1
        num-to-keep: 25
    - raw:
        xml: |
          <com.sonyericsson.rebuild.RebuildSettings plugin="rebuild@1.25">
          <autoRebuild>false</autoRebuild>
          <rebuildDisabled>false</rebuildDisabled>
          </com.sonyericsson.rebuild.RebuildSettings>
    publishers:
    - post-tasks:
      - escalate-status: false
        matches:
        - log-text: null
          operator: OR
        run-if-job-successful: false
        script: |-
          #!/bin/bash
          echo test
    triggers: []
    wrappers: []

I would hope that it would either include raw xml or convert the build-timeout wrapper to its jjb-equivalent:

    wrappers:
    - timeout:
        timeout: 5
        fail: true

But this doesn't happen. Means I can't use jenkins-job-wrecker <-> jenkins-job-builder repeatedly as it misses that stanza of timeouts. May also happen with other buildWrappers.

Thanks for the great program though! Its a real life-saver.

Thanks for the bug report. I wonder why we're skipping BuildTimeoutWrapper entirely there. Like you said, we should at least be providing the raw XML.

v1.4.4 has this fix. Thanks Greg!

Thanks for the quick merge!