2

I have used the Blue Ocean plugin to create a Jenkins job that automatically uses the Jenkinsfile (declarative pipeline) to build and report the status back to GitHub. That all works fine.

The issue I have is that I cannot get old builds deleted. The job shows as a repository and I have configured it to keep a maximum of 5 builds. But I noticed that the branches indexed, including the master branch, also have their own configuration. I tried setting up the old builds deletion but there’s no save button! I thought this was because the configuration propagates from the repository to the branches, but it has no effect. How can I get this to work?

2 Answers 2

4

Certain job properties are adjusted using directives in Jenkinsfiles and not the configuration in the web UI. In your Jenkinsfile:

properties([
  // only keep 25 builds to prevent disk usage from growing out of control
  buildDiscarder(
    logRotator(
      artifactDaysToKeepStr: '', 
      artifactNumToKeepStr: '', 
      daysToKeepStr: '', 
      numToKeepStr: '25',
    ),
  ),
])

You may of course adjust the various parameters to suit your needs.

1
  • Now it makes sense that the GUI view is read-only for branches, I see it reflects the properties set in their respective Jenkinsfiles. This is probably an effect of the multi-branch plugin. I placed the properties snippet above the pipeline directive on the declarative pipeline.
    – Nagev
    Aug 21, 2018 at 12:11
1

Unsure which Jenkins version brought the update, but the syntax has changed. Modifying jayhendren's example:

options {
  // only keep 25 builds to prevent disk usage from growing out of control
  buildDiscarder(
    logRotator(
      artifactDaysToKeepStr: '', 
      artifactNumToKeepStr: '', 
      daysToKeepStr: '', 
      numToKeepStr: '25',
    ),
  ),
}
1

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.