-
Notifications
You must be signed in to change notification settings - Fork 0
/
container_clean_up.groovy
31 lines (28 loc) · 1 KB
/
container_clean_up.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
pipelineJob('Container Cleanup') {
definition {
cps {
script('''
pipeline {
agent any
stages {
stage('Stopping all Containers') {
steps {
echo "Stopping all Containers"
sh "sudo docker ps -a -q"
// sh (script:'sudo docker stop $(sudo docker ps -a -q)', returnStdout: true)
}
}
stage('Removing all Containers') {
steps {
echo "Removing all Containers"
sh "sudo docker ps -a -q"
sh (script:'sudo docker rm $(sudo docker ps -a -q)', returnStdout: true)
}
}
}
}
''')
sandbox()
}
}
}