LogRotator dsl has no affect

696 views
Skip to first unread message

Wesley Connor

unread,
Nov 16, 2015, 10:09:57 AM11/16/15
to job-dsl-plugin


Jenkins - 1.638

Job Dsl - 1.40

I am configuring a mavenJob to enable the 'logrotator' via 'Discard Old Builds' to remove builds after 10 builds but it does not produce any visible change to the job


I have produced the simplest job here

mavenJob('example') {
  logRotator(-1,10)
}

Which produces the following xml 

<?xml version="1.0" encoding="UTF-8"?><maven2-moduleset>
    <actions/>
    <description/>
    <keepDependencies>false</keepDependencies>
    <properties/>
    <scm class="hudson.scm.NullSCM"/>
    <canRoam>true</canRoam>
    <disabled>false</disabled>
    <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
    <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
    <triggers class="vector"/>
    <concurrentBuild>false</concurrentBuild>
    <aggregatorStyleBuild>true</aggregatorStyleBuild>
    <incrementalBuild>false</incrementalBuild>
    <ignoreUpstremChanges>true</ignoreUpstremChanges>
    <archivingDisabled>false</archivingDisabled>
    <resolveDependencies>false</resolveDependencies>
    <processPlugins>false</processPlugins>
    <mavenValidationLevel>-1</mavenValidationLevel>
    <runHeadless>false</runHeadless>
    <publishers/>
    <buildWrappers/>
    <logRotator>
        <daysToKeep>-1</daysToKeep>
        <numToKeep>10</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
    </logRotator>



And the icon and feature is unchanged in the jenkins gui

If I manually click the 'Discard Old Builds' and click the options I desire

the xml changes to this

<?xml version='1.0' encoding='UTF-8'?>
<maven2-moduleset plugin="maven-...@2.12.1">
  <actions/>
  <description></description>
  <logRotator class="hudson.tasks.LogRotator">
    <daysToKeep>-1</daysToKeep>
    <numToKeep>10</numToKeep>
    <artifactDaysToKeep>-1</artifactDaysToKeep>
    <artifactNumToKeep>-1</artifactNumToKeep>
  </logRotator>
  <keepDependencies>false</keepDependencies>
  <properties>
    <jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>-1</daysToKeep>
        <numToKeep>10</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>
    <org.bstick12.jenkinsci.plugins.leastload.LeastLoadDisabledProperty plugin="leas...@1.0.3">
      <leastLoadDisabled>false</leastLoadDisabled>
    </org.bstick12.jenkinsci.plugins.leastload.LeastLoadDisabledProperty>
    <com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty plugin="nagi...@1.16">
      <optOut>false</optOut>
    </com.chikli.hudson.plugin.naginator.NaginatorOptOutProperty>
  </properties>
  <scm class="hudson.scm.NullSCM"/>
  <canRoam>true</canRoam>
  <disabled>false</disabled>
  <blockBuildWhenDownstreamBuilding>false</blockBuildWhenDownstreamBuilding>
  <blockBuildWhenUpstreamBuilding>false</blockBuildWhenUpstreamBuilding>
  <triggers/>
  <concurrentBuild>false</concurrentBuild>
  <aggregatorStyleBuild>true</aggregatorStyleBuild>
  <incrementalBuild>false</incrementalBuild>
  <ignoreUpstremChanges>true</ignoreUpstremChanges>
  <archivingDisabled>false</archivingDisabled>
  <siteArchivingDisabled>false</siteArchivingDisabled>
  <fingerprintingDisabled>false</fingerprintingDisabled>
  <resolveDependencies>false</resolveDependencies>
  <processPlugins>false</processPlugins>
  <mavenValidationLevel>-1</mavenValidationLevel>
  <runHeadless>false</runHeadless>
  <disableTriggerDownstreamProjects>false</disableTriggerDownstreamProjects>
  <blockTriggerWhenBuilding>true</blockTriggerWhenBuilding>
  <settings class="jenkins.mvn.DefaultSettingsProvider"/>
  <globalSettings class="jenkins.mvn.DefaultGlobalSettingsProvider"/>
  <reporters/>
  <publishers/>
  <buildWrappers/>
  <prebuilders/>
  <postbuilders/>
  <runPostStepsIfResult>
    <name>FAILURE</name>
    <ordinal>2</ordinal>
    <color>RED</color>
    <completeBuild>true</completeBuild>
  </runPostStepsIfResult>



This code is not produced by the logRotator dsl option seems to be 

<jenkins.model.BuildDiscarderProperty>
      <strategy class="hudson.tasks.LogRotator">
        <daysToKeep>-1</daysToKeep>
        <numToKeep>10</numToKeep>
        <artifactDaysToKeep>-1</artifactDaysToKeep>
        <artifactNumToKeep>-1</artifactNumToKeep>
      </strategy>
    </jenkins.model.BuildDiscarderProperty>

Is this something that I am doing incorrectly? 
Is it a clash with another plugin I have installed perhaps

Your help is apprecated

Thanks

wes

Matt Sheehan

unread,
Nov 16, 2015, 12:14:38 PM11/16/15
to job-dsl-plugin
It looks like something that was changed in Jenkins core v1.637 https://github.com/jenkinsci/jenkins/commit/1cbbb23923d002dc6e676bfcaecbf8cbddb2e974

I think you'll have to use the configure block for now, until support is added for the newer model.

--
You received this message because you are subscribed to the Google Groups "job-dsl-plugin" group.
To unsubscribe from this group and stop receiving emails from it, send an email to job-dsl-plugi...@googlegroups.com.
To post to this group, send email to job-dsl...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/job-dsl-plugin/f29c6d0c-bff7-4b5d-9b7c-7987d1da4eb9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Wesley Connor

unread,
Nov 17, 2015, 2:20:20 AM11/17/15
to job-dsl-plugin
Ok thanks for your help, I was able to reproduce functionality with this


        logRotator(-1, 10)
        configure {
            it / 'properties' / 'jenkins.model.BuildDiscarderProperty' {
                strategy {
                    'daysToKeep'('-1')
                    'numToKeep'('10')
                    'artifactDaysToKeep'('-1')
                    'artifactNumToKeep'('-1')
                }
            }
        }
Reply all
Reply to author
Forward
0 new messages