/
Jenkinsfile.groovy
44 lines (38 loc) · 1.09 KB
/
Jenkinsfile.groovy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
def functions
pipeline {
agent { label "maintenance" }
// add cron job :)
// triggers {
// “At 05:05.”
// https://crontab.guru/
// cron('5 5 * * *')
// }
parameters {
string(name: 'DAYS', defaultValue: '35', description: 'A branch is defined as stale if the last commit is older than DAYS.')
booleanParam(name: 'UPDATE_REMOTE', defaultValue: true, description: 'Purges stale branches on remote otherwise only locally.')
}
stages {
stage('Prepare') {
steps {
script {
functions = load "stale-bot/PipelineFunctions.groovy"
}
}
}
stage('Clean up the stale branches') {
when {
expression { script { !functions.isPublicBranch() } }
}
steps {
script {
functions.purgeBranchesOlderThan(params.DAYS.toInteger(), params.UPDATE_REMOTE.toBoolean())
}
}
}
}
post {
cleanup {
cleanWs()
}
}
}