Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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