2018-05-03 10:11:30 +02:00
|
|
|
pipeline {
|
2018-05-03 11:02:59 +02:00
|
|
|
agent any
|
2018-05-03 10:11:30 +02:00
|
|
|
stages {
|
|
|
|
stage('Build') {
|
|
|
|
steps {
|
2018-05-03 11:09:54 +02:00
|
|
|
sh 'docker build --pull -t workout:jenkins .'
|
2018-05-03 10:11:30 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-03 11:26:19 +02:00
|
|
|
stage('test') {
|
|
|
|
steps {
|
2018-05-03 11:40:33 +02:00
|
|
|
sh 'docker container stop pg || true'
|
|
|
|
sh 'docker container stop workout || true'
|
2018-05-03 11:47:22 +02:00
|
|
|
sh 'docker network create test_workout || true'
|
2018-05-03 11:40:33 +02:00
|
|
|
sh 'docker container run --rm --name pg --network test_workout -d postgres'
|
2018-05-03 11:47:22 +02:00
|
|
|
sh 'docker container run --rm --name workout --network test_workout -p 8000:8000 -e DATABASE_URL=postgres://postgres:postgres@pg:5432/postgres -e SECRET_KEY=secret -d workout:jenkins /bin/bash'
|
2018-05-03 11:40:33 +02:00
|
|
|
sh 'curl http://localhost:8000'
|
2018-05-03 11:26:19 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-03 10:11:30 +02:00
|
|
|
}
|
2018-05-03 11:29:05 +02:00
|
|
|
post {
|
|
|
|
always {
|
2018-05-03 11:47:22 +02:00
|
|
|
sh 'docker container stop pg'
|
|
|
|
sh 'docker container stop workout'
|
|
|
|
sh 'docker network remove test_workout'
|
2018-05-03 11:29:05 +02:00
|
|
|
}
|
|
|
|
}
|
2018-05-03 11:02:34 +02:00
|
|
|
}
|