Skip to content

Instantly share code, notes, and snippets.

@madelaney
Created October 3, 2018 14:43
Show Gist options
  • Save madelaney/154e1c89f093855fc067bf684300f47f to your computer and use it in GitHub Desktop.
Save madelaney/154e1c89f093855fc067bf684300f47f to your computer and use it in GitHub Desktop.
Jenkins file with long running docker image.
properties([
disableConcurrentBuilds(),
pipelineTriggers([cron('@midnight')]),
buildDiscarder(logRotator(numToKeepStr: '2'))
])
node ('docker') {
stage('Pull') {
image = docker.image('fancypantsimage:latest')
image.pull()
}
stage('Run') {
def ARGS = [
"-v ${WORKSPACE}/data:/repos/data",
"-v ${WORKSPACE}/results:/results"
]
def container = image.run(ARGS.join(' '))
def running = true
while (running) {
status = sh returnStdout: true, script: "docker inspect -f {{.State.Running}} ${container.id}"
running = status.toBoolean()
sleep 20
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment