-
Notifications
You must be signed in to change notification settings - Fork 1
/
Jenkinsfile
38 lines (35 loc) · 982 Bytes
/
Jenkinsfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#!/usr/bin/env groovy
pipeline {
agent any
environment {
DOCKER_LOCATION = './docker'
COMPOSE_FILE = "${DOCKER_LOCATION}/docker-compose.yml"
COMPOSE_PROJECT_NAME = "mysql_backup_${GIT_COMMIT.take(8)}_${BUILD_NUMBER}"
}
stages {
stage('Build') {
steps {
echo 'Starting container'
sh "docker-compose -f ${COMPOSE_FILE} up -d"
}
}
stage('Prepare') {
steps {
echo 'Running go get'
sh "docker exec -i ${COMPOSE_PROJECT_NAME}_go_1 bash -c 'go get -t ./...'"
}
}
stage('Test') {
steps {
echo 'Running go tests'
sh "docker exec -i ${COMPOSE_PROJECT_NAME}_go_1 bash -c 'go test ./...'"
}
}
}
post {
always {
echo "Removing docker container"
sh "docker-compose down || true"
}
}
}