-
Notifications
You must be signed in to change notification settings - Fork 5
/
Jenkinsfile
68 lines (66 loc) · 2 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
pipeline {
agent any
options {
disableConcurrentBuilds()
lock resource: 'cilantro'
}
stages {
stage('Prepare') {
steps {
echo 'Preparing..'
sh 'make init'
sh 'docker-compose build && docker-compose up -d'
}
}
stage('Test backend') {
steps {
echo 'Testing backend..'
sleep 10
sh 'make test-backend'
}
}
stage('Test frontend (unit)') {
steps {
echo 'Testing frontend (unit)..'
sh 'make test-frontend'
}
}
stage('Build code documentation') {
when{
branch 'master'
}
steps {
echo 'Building docu..'
sh 'make build-doc'
}
}
}
post {
always {
sh 'make down'
sh 'docker-compose logs > docker.log -t'
sh 'docker-compose down -v'
// clean documentation residues
sh 'git clean -f'
sh 'rm -rf doc/_build/doctrees/'
archiveArtifacts artifacts: 'docker.log', fingerprint: true
}
success {
script { // Send back-to-normal notification
if (env.BRANCH_NAME == 'master') {
if (currentBuild.previousBuild.result != 'SUCCESS') {
rocketSend channel: 'devs', message: "Back to Normal: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})", color: 'GREEN'
}
}
}
}
failure {
sh 'docker-compose logs' // write docker logs to Jenkins' logs
script {
if (env.BRANCH_NAME == 'master') {
rocketSend channel: 'devs', message: "FAILED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]' (${env.BUILD_URL})", color: 'RED'
}
}
}
}
}