I would like to configure the buildDiscarder
differently depending on a global variable. Currently I have
options {
buildDiscarder(logRotator(numToKeepStr: '5'))
}
but I'm looking for something like
// BROKEN
options {
if ("${SOME_VAR}" == 'some_val') {
buildDiscarder(logRotator(numToKeepStr: '5'))
} else {
buildDiscarder(logRotator(daysToKeepStr: '7'))
}
}
Is there any way to achieve this kind of behaviour in a Jenkins declarative pipeline? I don't think I can use a script
/when
/expression
block here, or at least it didn't work when I tried.
Sources/ideas that I've stumbled upon which didn't work: 1, 2, 3, 4, 5, 6