Skip to content

Commit

Permalink
Cleanup workspace
Browse files Browse the repository at this point in the history
Signed-off-by: John Zila <[email protected]>
  • Loading branch information
jzila committed Jul 21, 2016
1 parent c28103f commit 68d7337
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 17 deletions.
40 changes: 23 additions & 17 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@
if (env.CHANGE_TITLE && env.CHANGE_TITLE.contains('[ci-skip]')) {
println "Skipping build because PR title contains [ci-skip]"
} else {
nodeWithCleanup("ec2-fleet") {
nodeWithCleanup("ec2-fleet", {
sh 'docker rm -v $(docker ps --filter status=exited -q 2>/dev/null) 2>/dev/null || echo "No Docker containers to remove"'
sh 'docker rmi $(docker images --filter dangling=true -q --no-trunc 2>/dev/null) 2>/dev/null || echo "No Docker images to remove"'
}) {
properties([
[$class: "BuildDiscarderProperty",
strategy: [$class: "LogRotator",
Expand Down Expand Up @@ -172,8 +175,7 @@ if (env.CHANGE_TITLE && env.CHANGE_TITLE.contains('[ci-skip]')) {
)
},
test_windows: {
nodeWithCleanup('windows') {
deleteDir()
nodeWithCleanup('windows', {}) {
def BASEDIR=pwd()
def GOPATH="${BASEDIR}/go"
withEnv([
Expand Down Expand Up @@ -241,8 +243,7 @@ if (env.CHANGE_TITLE && env.CHANGE_TITLE.contains('[ci-skip]')) {
}
},
test_osx: {
nodeWithCleanup('osx') {
deleteDir()
nodeWithCleanup('osx', {}) {
def BASEDIR=pwd()
def GOPATH="${BASEDIR}/go"
withEnv([
Expand Down Expand Up @@ -336,6 +337,23 @@ def testNixGo(prefix) {
}
}

def nodeWithCleanup(label, cleanup, closure) {
def wrappedClosure = {
try {
deleteDir()
closure()
} finally {
try {
cleanup()
} catch (ex) {
println "Unable to cleanup: ${ex.getMessage()}"
}
deleteDir()
}
}
node(label, wrappedClosure)
}

// Need to separate this out because cause is not serializable and thus state
// cannot be saved. @NonCPS makes this method run as native and thus cannot be
// re-entered.
Expand All @@ -350,15 +368,3 @@ def getCauseString() {
return "other"
}
}

def nodeWithCleanup(label, closure) {
def wrappedClosure = {
try {
deleteDir()
closure()
} finally {
deleteDir()
}
}
node(label, wrappedClosure)
}
1 change: 1 addition & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
links:
- mysql.local
- gregor.local
entrypoint: ["run/startup_for_container.sh"]
environment:
- KEYBASE_RUN_MODE=devel
# - KEYBASE_NO_GREGORD_LAUNCH=true
Expand Down

0 comments on commit 68d7337

Please sign in to comment.