-
Notifications
You must be signed in to change notification settings - Fork 12
Build number range condition
Damian Szczepanik edited this page Dec 8, 2019
·
8 revisions
This page presents example how to use BuildNumberRange condition:
- delete build with build number greater or equal to 70
- delete build with build number between 73~75 included
pipeline {
agent any
options {
buildDiscarder(
BuildHistoryManager([
[
conditions: [ BuildNumberRange(maxBuildNumber: 75, minBuildNumber: 73)],
actions: [ DeleteBuild() ]
],
[
conditions: [
BuildNumberRange(maxBuildNumber: 70)],
actions: [ DeleteBuild() ]
]
])
)
}
stages {
stage('Demo') {
steps {
echo "Hello!"
}
}
}
}Following presents build history before and after running above configuration. Numbers refer to build number.
| Before | After | Reason |
|---|---|---|
[ 23] |
[ 23] |
Matched by first rule. None action performed. |
[ 24] |
[ 24] |
Matched by first rule. None changes performed. This is the last build matched by this rule because of matchAtMost: 2
|
[ 25] |
[ 25] |
Matched by second rule, artifact has been deleted |
[ 30] |
[ 30] |
Matched by second rule. Artifact should be removed but it is not published. |
[ 31] |
[ 31] |
Matched by second rule. Artifact should be removed but it was not present. This is the last build matched by this rule because of matchAtMost: 3
|
[ 32] |
Matched by second rule. Build has been removed. |
|
[ 35] |
Matched by second rule. Build has been removed. |