1
0
mirror of synced 2024-11-22 12:26:02 +03:00
mg-transport-telegram/Jenkinsfile

81 lines
1.9 KiB
Plaintext
Raw Normal View History

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-31 15:03:57 +03:00
sh 'cp config_test.yml.dist config_test.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-31 15:03:57 +03:00
compose 'run --rm 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}"
}