forked from cattles/spring-cloud-event-sourcing-example
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathskate_pub.groovy
134 lines (111 loc) · 7.25 KB
/
skate_pub.groovy
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
122
123
124
125
126
127
128
129
130
131
132
133
134
def gitRepo = "[email protected]:Dataman-Cloud/skate.git"
publicRegistryUrl = "demoregistry.dataman-inc.com"
publicImagePrefix = "${publicRegistryUrl}/skate"
publicRegistryUsername = "guangzhou"
publicRegistryPassword = "Gz-regsistry-2017@"
workRootDir = "/home/apps/jenkins-home/workspace/skate"
publicRepositoryId = "releases-public"
workRootDir = "/home/apps/jenkins-home/workspace/skate"
targetdockerfile = "target/"
sourcedockerfile = "src/main/docker"
node("master") {
stage("Prepare") {
sh "echo version is ${VERSION}, IS_PUSH is ${IS_PUSH}"
git branch: "master", url: "${gitRepo}"
sh "git pull origin dev"
sh "echo 'execute replaceVersion'"
replaceVersion()
}
stage("Release-Build") {
//sh "mvn -DskipTests clean package"
sh "mvn -DskipTests clean package -Dspring.profiles.active=docker"
}
stage("cp-dockerfile") {
sh "cp config-service/${sourcedockerfile}/Dockerfile config-service/${targetdockerfile}"
sh "cp discovery-service/${sourcedockerfile}/Dockerfile discovery-service/${targetdockerfile}"
sh "cp edge-service/${sourcedockerfile}/Dockerfile edge-service/${targetdockerfile}"
sh "cp user-service/${sourcedockerfile}/Dockerfile user-service/${targetdockerfile}"
sh "cp account-service/${sourcedockerfile}/Dockerfile account-service/${targetdockerfile}"
sh "cp shopping-cart-service/${sourcedockerfile}/Dockerfile shopping-cart-service/${targetdockerfile}"
sh "cp catalog-service/${sourcedockerfile}/Dockerfile catalog-service/${targetdockerfile}"
sh "cp inventory-service/${sourcedockerfile}/Dockerfile inventory-service/${targetdockerfile}"
sh "cp order-service/${sourcedockerfile}/Dockerfile order-service/${targetdockerfile}"
sh "cp online-store-web/${sourcedockerfile}/Dockerfile online-store-web/${targetdockerfile}"
sh "cp hystrix-dashboard/${sourcedockerfile}/Dockerfile hystrix-dashboard/${targetdockerfile}"
}
//������push tag ��ȷ�����������в����ɹ�
//�ƹ���image�ֿ�
pushImageToPublicRegistry()
stage("Cleanup") {
//�ָ�����
sh "echo 'Reset the version to master-SNAPSHOT'"
sh "git reset --hard"
}
}
/** ��images�������IJֿ�**/
def pushImageToPublicRegistry() {
if (params.IS_PUSH == "Yes") {
stage("Push-image-config") {
sh "docker build -t ${publicImagePrefix}/config-service:${VERSION} config-service/${targetdockerfile}"
sh "docker login -u ${publicRegistryUsername} -p ${publicRegistryPassword} ${publicRegistryUrl}/${targetdockerfile}"
sh "docker push ${publicImagePrefix}/config-service:${VERSION}"
}
stage("Push-image-discovery") {
sh "docker build -t ${publicImagePrefix}/discovery-service:${VERSION} discovery-service/${targetdockerfile}"
sh "docker login -u ${publicRegistryUsername} -p ${publicRegistryPassword} ${publicRegistryUrl}/${targetdockerfile}"
sh "docker push ${publicImagePrefix}/discovery-service:${VERSION}"
}
stage("Push-image-edge") {
sh "docker build -t ${publicImagePrefix}/edge-service:${VERSION} edge-service/${targetdockerfile}"
sh "docker login -u ${publicRegistryUsername} -p ${publicRegistryPassword} ${publicRegistryUrl}/${targetdockerfile}"
sh "docker push ${publicImagePrefix}/edge-service:${VERSION}"
}
stage("Push-image-biz") {
sh "docker build -t ${publicImagePrefix}/user-service:${VERSION} user-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/account-service:${VERSION} account-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/shopping-cart-service:${VERSION} shopping-cart-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/catalog-service:${VERSION} catalog-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/inventory-service:${VERSION} inventory-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/order-service:${VERSION} order-service/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/online-store-web:${VERSION} online-store-web/${targetdockerfile}"
sh "docker build -t ${publicImagePrefix}/hystrix-dashboard:${VERSION} hystrix-dashboard/${targetdockerfile}"
sh "docker login -u ${publicRegistryUsername} -p ${publicRegistryPassword} ${publicRegistryUrl}"
sh "docker push ${publicImagePrefix}/user-service:${VERSION}"
sh "docker push ${publicImagePrefix}/account-service:${VERSION}"
sh "docker push ${publicImagePrefix}/shopping-cart-service:${VERSION}"
sh "docker push ${publicImagePrefix}/catalog-service:${VERSION}"
sh "docker push ${publicImagePrefix}/inventory-service:${VERSION}"
sh "docker push ${publicImagePrefix}/order-service:${VERSION}"
sh "docker push ${publicImagePrefix}/online-store-web:${VERSION}"
sh "docker push ${publicImagePrefix}/hystrix-dashboard:${VERSION}"
}
}
}
/** �滻�汾��*/
def replaceVersion() {
sh "echo Replace master-SNAPSHOT to ${VERSION} in pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' config-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' discovery-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' hystrix-dashboard/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' edge-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' user-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' account-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' shopping-cart-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' catalog-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' inventory-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' order-service/pom.xml"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' online-store-web/pom.xml"
sh "echo Replace master-SNAPSHOT to ${VERSION} in Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' config-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' discovery-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' hystrix-dashboard/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' edge-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' user-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' account-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' shopping-cart-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' catalog-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' inventory-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' order-service/${sourcedockerfile}/Dockerfile"
sh "sed -i 's|master-SNAPSHOT|${VERSION}|g\' online-store-web/${sourcedockerfile}/Dockerfile"
}