'Is it possible to have a Jenkins build not update build history?
I'm using multi-branch pipelines.
Is it possible to have a multi-branch pipeline not update build history, or have a pipeline delete the history of it's run after it completes?
I have some runs I do not want to appear in the build history of a multi-branch job. I can delete runs manually, but I want to do this from inside a pipeline.
I want to conditionally have code that tells Jenkins "hey delete the build history of this build that just ran".
Is this possible?
EDIT
I was thinking of another possible way of achieving this. I can access hudson.model.Hudson outside the pipeline directive. If there are methods available that would allow you to list and discard specific builds I could call that before a job starts which would purge all old builds of my choosing.
Can I do something like this inside a multibranch pipeline? Jenkins.instance.getItemByFullName('JobName').builds.findAll { it.number > 10 && it.number < 1717 }.each { it.delete() }
I'm attempting to do this via a class, but I cannot figure out how to get access to builds
package com.util
@Grab(group='org.jvnet.hudson.main', module='hudson-core', version='2.2.1')
import hudson.model.Hudson
class reflect implements Serializable {
def static purgeSpecificBuilds(name){
def hi = Hudson.instance
// This much I can get
def job = hi.getItemByFullName(name)
// But the object returned has no "builds" property
job.builds.findAll { it.buildCause == "filter a specific build cause type"}.each { it.delete() }
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
