-
Notifications
You must be signed in to change notification settings - Fork 12
Build number range condition
Damian Szczepanik edited this page Dec 14, 2019
·
8 revisions
This page presents example how to use BuildNumberRange condition:
- delete build with build number less or equal to 70
- delete build with build number between 73~75, both 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 Jenkins job number.
| Before | After | Reason |
|---|---|---|
[ 80] |
[ 80] |
None rule matched. |
[ 76] |
[ 76] |
None rule matched. |
[ 75] |
Matched by first rule. Build has been removed. |
|
[ 73] |
Matched by first rule. Build has been removed. |
|
[ 71] |
[ 71] |
None rule matched. |
[ 70] |
Matched by second rule. Build has been removed. |
|
[ 2] |
Matched by second rule. Build has been removed. |