Skip to content

Instantly share code, notes, and snippets.

@sdorra
Created October 23, 2016 20:05
Show Gist options
  • Save sdorra/eab4ad3689de0cd5c5e638d8fbb9db16 to your computer and use it in GitHub Desktop.
Save sdorra/eab4ad3689de0cd5c5e638d8fbb9db16 to your computer and use it in GitHub Desktop.
Docker jenkins pipeline example
node('docker') {
stage 'start database'
docker.image('redis:3.0.7-alpine').withRun { c ->
def ip = hostIp(c)
stage 'client set'
docker.image('redis:3.0.7-alpine').inside {
sh "redis-cli -h ${ip} set test 123"
}
stage 'client get'
docker.image('redis:3.0.7-alpine').inside {
sh "redis-cli -h ${ip} get test"
}
stage 'client del'
docker.image('redis:3.0.7-alpine').inside {
sh "redis-cli -h ${ip} del test"
}
}
}
def hostIp(container) {
sh "docker inspect -f {{.NetworkSettings.IPAddress}} ${container.id} > host.ip"
readFile('host.ip').trim()
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment