Created
October 23, 2016 20:05
-
-
Save sdorra/eab4ad3689de0cd5c5e638d8fbb9db16 to your computer and use it in GitHub Desktop.
Docker jenkins pipeline example
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
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