28 lines
853 B
Groovy
28 lines
853 B
Groovy
pipeline {
|
|
agent any
|
|
stages {
|
|
stage('Build') {
|
|
steps {
|
|
sh 'docker build --pull -t workout:jenkins .'
|
|
}
|
|
}
|
|
stage('test') {
|
|
steps {
|
|
sh 'docker container stop pg || true'
|
|
sh 'docker container stop workout || true'
|
|
sh 'docker network create test_workout || true'
|
|
sh 'docker container run --rm --name pg --network test_workout -d postgres'
|
|
sh 'sleep 5'
|
|
sh 'docker container run --rm --name workout --network test_workout -p 8000:8000 -e DJANGO_ENV=dev -e DATABASE_URL=postgres://postgres:postgres@pg:5432/postgres -e SECRET_KEY=secret -d workout:jenkins'
|
|
echo 'Do some testing here...'
|
|
}
|
|
}
|
|
}
|
|
post {
|
|
always {
|
|
sh 'docker container stop pg'
|
|
sh 'docker container stop workout'
|
|
sh 'docker network remove test_workout'
|
|
}
|
|
}
|
|
}
|