-
-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathJenkinsfile_old
More file actions
executable file
·107 lines (97 loc) · 4.24 KB
/
Jenkinsfile_old
File metadata and controls
executable file
·107 lines (97 loc) · 4.24 KB
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
pipeline {
agent { label 'docker' }
stages {
stage('Build') {
when {
not {
changelog '.*^\\[ci skip\\] .+$'
}
}
steps {
// Print all the environment variables.
sh 'printenv'
sh 'echo $GIT_BRANCH'
sh 'echo $GIT_COMMIT'
echo 'Construction des images'
sh 'docker pull delain/tests_unitaires'
sh 'docker-compose -f docker-compose-tu.yml build'
echo 'Arrêt des instances précédentes '
sh 'docker-compose -f docker-compose-tu.yml down --remove-orphans'
// par séurité...
sh 'if docker ps |grep webtu > /dev/null; then docker rm -f webtu; fi'
sh 'if docker ps |grep delain_dbtu > /dev/null; then docker rm -f delain_dbtu; fi'
echo 'Lancement du docker-compose'
sh 'docker-compose -f docker-compose-tu.yml up -d'
}
}
stage('Test') {
when {
not {
changelog '.*^\\[ci skip\\] .+$'
}
}
steps {
echo "Wait for postgres to be up"
sh 'docker exec webtu /home/delain/delain/web/tests/wait.sh'
echo 'PHP Unit tests'
sh 'web/tests/phpunit_docker-tu.sh'
}
}
stage('Deploy')
{
agent { label 'backenddelain' }
when { branch 'master' }
steps {
echo "Git pull"
sh "su - delain -c 'cd /home/delain/delain && git pull'"
echo "Empty cache"
sh "rm -rf /home/delain/delain/cache/*"
echo "Livraisons SQL"
sh "su - delain /home/delain/delain/shell/livraisons.sh"
}
}
stage('Generate api doc')
{
agent { label 'backenddelain' }
when { branch 'master' }
steps {
echo "Generate api doc"
sh "su - delain -c '/usr/bin/apidoc -i /home/delain/delain/web/www/api/v2 -o /home/delain/delain/web/www/api/doc'"
}
}
}
post {
always {
// Always cleanup after the build.
sh "docker-compose -f ${WORKSPACE}/docker-compose-tu.yml down"
sh 'if docker ps |grep webtu > /dev/null; then docker rm -f webtu; fi'
sh 'if docker ps |grep delain_dbtu > /dev/null; then docker rm -f delain_dbtu; fi'
sh 'docker system prune -f'
slackSend channel: '#general',
color: 'green',
message: "Livraison de ${currentBuild.fullDisplayName} termine."
}
failure {
mail to: 'stephane.dewitte@gmail.com',
subject: "Failed Pipeline: ${currentBuild.fullDisplayName}",
body: "<b>Error on project</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}",
charset: 'UTF-8',
mimeType: 'text/html',
from: 'stephane@sdewitte.net'
slackSend channel: '#general',
color: 'red',
message: "The pipeline ${currentBuild.fullDisplayName} is down."
}
changed {
mail to: 'stephane.dewitte@gmail.com',
subject: "Unstable Pipeline: ${currentBuild.fullDisplayName}",
body: "<b>Unstable</b><br>Project: ${env.JOB_NAME} <br>Build Number: ${env.BUILD_NUMBER} <br> URL de build: ${env.BUILD_URL}",
charset: 'UTF-8',
mimeType: 'text/html',
from: 'stephane@sdewitte.net'
slackSend channel: '#general',
color: 'orange',
message: "The pipeline ${currentBuild.fullDisplayName} is unstable."
}
}
}