|
Some further information:
Updating a job via the API does not enable the Discard Old Builds plugin
I took a job that did not have Discard Old Builds configured, created a modified version of the config.xml which added the following:
<org.jenkinsci.plugins.workflow.job.properties.BuildDiscarderProperty>
<strategy class="hudson.tasks.LogRotator">
<daysToKeep>3</daysToKeep>
<numToKeep>-1</numToKeep>
<artifactDaysToKeep>-1</artifactDaysToKeep>
<artifactNumToKeep>-1</artifactNumToKeep>
</strategy>
</org.jenkinsci.plugins.workflow.job.properties.BuildDiscarderProperty>
...and performed an update call to the Jenkins API via the following:
This resulted in the job's config.xml file containing the correct configuration, but the Jenkins UI did not show that Discard Old Builds had been enabled.
The real issue seems to relate to reloading config from disk
You don't even have to fully restart Jenkins; simply reloading the configuration from disk via the Jenkins UI will cause Discard Old Builds to be disabled. It just so happens that configuration is also reloaded from disk on a Jenkins restart. In addition, I confirmed that this happens with...
-
A job which previously had Discard Old Builds enabled via the UI, and working: After a reload from disk, it is disabled in the UI, and not working, despite having a proper config.xml.
-
A job which previously did NOT have Discard Old Builds enabled via the UI, but that I had updated config.xml to contain the proper XML configuration, before reloading from disk.
Summary
In all cases, the end result was that the job's config.xml contained the proper configuration, but the UI shows the box as unchecked, and the actual discarding of builds does not occur.
|