-
Notifications
You must be signed in to change notification settings - Fork 34
/
Copy pathJenkinsfile
121 lines (120 loc) · 2.67 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
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
pipeline{
agent{
node{
label '611177209'
}
}
environment{
DOCKERHUB_CREDENTIALS = credentials('611177209-dockerhub')
}
options {
skipDefaultCheckout(true)
}
stages{
stage('Clean old DOCs & chekcout SCM'){
steps{
cleanWs()
checkout scm
}
}
stage('verify tools'){
steps{
sh '''
docker info
docker version
docker-compose version
'''
}
}
stage('Login Dockerhub'){
steps{
sh '''
echo $DOCKERHUB_CREDENTIALS_PSW | docker login -u $DOCKERHUB_CREDENTIALS_USR --password-stdin
'''
}
}
stage('Build image for application'){
steps{
sh '''
docker-compose build
'''
}
}
stage('Rename && Push image to Dockerhub'){
steps{
sh '''
docker tag 611177209_ci4_service:latest zhunwei/611177209_ci4_service:latest
docker push zhunwei/611177209_ci4_service:latest
'''
}
}
stage('Start Container'){
steps{
sh '''
docker-compose up -d
'''
}
}
stage('Check Container'){
steps{
sh '''
docker ps -a
docker images
'''
}
}
// stage('Dependency installation'){
// steps{
// sh '''
// docker-compose exec -T ci4_service sh -c "cd /app && composer install"
// docker-compose restart
// '''
// }
// }
// stage('Environment Setting Up'){
// steps{
// script{
// sh '''
// cp app/env app/.env
// '''
// }
// }
// }
// stage('Database migrate'){
// steps{
// sh '''
// docker-compose exec -T ci4_service sh -c "php spark migrate"
// '''
// }
// }
// stage('Database seed'){
// steps{
// sh '''
// sleep 2
// docker-compose exec -T ci4_service sh -c "php spark migrate"
// docker-compose exec -T ci4_service sh -c "php spark db:seed Members"
// docker-compose exec -T ci4_service sh -c "php spark db:seed TodoLists"
// docker-compose up -d
// '''
// }
// }
// stage('Unit testing'){
// steps{
// sh '''
// docker-compose exec -T ci4_service sh -c "vendor/bin/phpunit --log-junit build/logs/blogger_unitTest.xml"
// ls
// '''
// junit 'app/build/logs/blogger_unitTest.xml'
// }
// }
}
post {
always {
sh '''
docker-compose down
docker system prune -a -f
docker logout
'''
}
}
}