2018-05-25 16:01:58 +03:00
|
|
|
pipeline {
|
|
|
|
agent {
|
|
|
|
label 't2medium'
|
|
|
|
}
|
|
|
|
|
|
|
|
options {
|
|
|
|
disableConcurrentBuilds()
|
|
|
|
}
|
|
|
|
|
2018-05-25 16:15:24 +03:00
|
|
|
environment {
|
|
|
|
HUB_URL = credentials('docker_hub_url')
|
|
|
|
HUB_PATH = credentials('docker_hub_path')
|
|
|
|
}
|
|
|
|
|
2018-05-25 16:01:58 +03:00
|
|
|
stages {
|
|
|
|
stage('Prepare') {
|
|
|
|
steps {
|
2018-05-29 17:20:56 +03:00
|
|
|
sh 'cp config_test.yml.dist config.yml'
|
|
|
|
compose 'up -d --build postgres_test'
|
|
|
|
compose 'run --rm mg_telegram_test make migrate_test'
|
2018-05-25 16:01:58 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Tests') {
|
|
|
|
steps {
|
2018-05-29 17:20:56 +03:00
|
|
|
compose 'run --rm --no-deps mg_telegram_test make jenkins_test'
|
2018-05-25 16:01:58 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
sh 'cat ./test-report.xml'
|
|
|
|
junit 'test-report.xml'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Docker Images') {
|
|
|
|
when {
|
|
|
|
branch 'master'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
withCredentials([usernamePassword(
|
|
|
|
credentialsId: 'docker-hub-credentials',
|
|
|
|
usernameVariable: 'HUB_USER',
|
|
|
|
passwordVariable: 'HUB_PASS'
|
|
|
|
)]) {
|
|
|
|
sh 'echo ${HUB_PASS} | docker login -u ${HUB_USER} --password-stdin ${HUB_URL}'
|
|
|
|
}
|
|
|
|
|
|
|
|
sh 'docker build -t ${HUB_URL}${HUB_PATH} ./'
|
|
|
|
sh 'docker push ${HUB_URL}${HUB_PATH}'
|
|
|
|
}
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
sh 'docker rmi ${HUB_URL}${HUB_PATH}:latest'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
compose 'down -v'
|
|
|
|
deleteDir ()
|
|
|
|
}
|
|
|
|
aborted {
|
|
|
|
echo "Aborted."
|
|
|
|
}
|
|
|
|
success {
|
|
|
|
echo "Success."
|
|
|
|
}
|
|
|
|
failure {
|
|
|
|
echo "Failure."
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
def compose(cmd) {
|
|
|
|
sh "docker-compose --no-ansi -f docker-compose-test.yml ${cmd}"
|
|
|
|
}
|