forked from hbang/MapsOpener
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
34 lines (32 loc) · 1.1 KB
/
Jenkinsfile
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
import org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.Whitelisted
/* Requires the Docker Pipeline plugin */
pipeline {
agent { docker { image 'maven:3.9.5-eclipse-temurin-17-alpine' } }
stages {
stage('build') {
steps {
sh 'mvn --version'
}
}
}
post {
aborted { script { handleAborted(Jenkins.instance.items)} }
}
}
@Whitelisted
void handleAborted(List<TopLevelItem> items) {
echo("Checking to see if we should delete the aborted job: " + env.JOB_NAME + " " + currentBuild.number)
items.each { item ->
if (item.class.canonicalName != 'com.cloudbees.hudson.plugins.folder.Folder') {
if (env.JOB_NAME.contains(item.name)) {
item.getAllJobs().each {
Job job = it
Run build = job.getBuildByNumber(currentBuild.number)
echo("Once this lands, this build will get deleted: "
+ build.getFullDisplayName() + build.getNumber())
build.delete()
}
}
}
}
}