Created
October 3, 2018 14:43
-
-
Save madelaney/154e1c89f093855fc067bf684300f47f to your computer and use it in GitHub Desktop.
Jenkins file with long running docker image.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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