-
Notifications
You must be signed in to change notification settings - Fork 11
Delete artifacts action
Damian Szczepanik edited this page Dec 8, 2019
·
14 revisions
This page presents example how to use DeleteArtifacts action:
- at most two the most recent build should be saved
- for at most three more artifacts should be deleted
- all the rest must be deleted
pipeline {
agent any
options {
buildDiscarder(
BuildHistoryManager([
[
continueAfterMatch: false,
matchAtMost: 2
],
[
actions : [ DeleteArtifacts() ],
continueAfterMatch: false,
matchAtMost : 3
],
[
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 |
---|---|---|
[ 23 ]with artifact |
[ 23 ]with artifact |
Matched by first rule. None action performed. |
[ 24 ]without artifact |
[ 24 ]without artifact |
Matched by first rule. None changes performed. This is the last build matched by this rule because of matchAtMost: 2
|
[ 25 ]with artifact |
[ 25 ]without artifact |
Matched by second rule, artifact has been deleted |
[ 30 ]without artifact |
[ 30 ]without artifact |
Matched by second rule. Artifact should be removed but it is not published. |
[ 31 ]without artifact |
[ 31 ]without artifact |
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 ]with artifact |
Matched by second rule. Build has been removed. |
|
[ 35 ]with artifact |
Matched by second rule. Build has been removed. |