-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
127 lines (93 loc) · 3.39 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
122
123
124
125
126
127
// TODO: Read Example http://engineering.teacherspayteachers.com/2017/05/16/unifying-deployments-for-microservices-via-jenkins.html
// TODO: Read https://wilsonmar.github.io/jenkins2-pipeline/
// TODO: Reference, https://github.com/jfrog/project-examples/tree/master/jenkins-examples/pipeline-examples/declarative-examples
def springBootMvnBuild(directory){
node{
dir(directory) {
sh 'mvn clean install'
}
}
}
stage 'checkout'
node{
checkout([
$class: 'GitSCM',
branches: [[name: '**']],
doGenerateSubmoduleConfigurations: false,
submoduleCfg: [],
userRemoteConfigs: [
[credentialsId: 'gitlab-3', name: 'origin', url: 'https://gitlab.worscipe.com/Mbd06b/bright.git'],
[credentialsId: '[email protected] priv key', name: 'github', url: '[email protected]:Mbd06b/bright.git']
],
extensions: [
[ $class: 'PreBuildMerge',
options: [
fastForwardMode: 'FF',
mergeRemote: 'github',
mergeTarget: 'development'
]
]
]
])
}
//
stage 'compile'
bootPipeline('parent')
dir('parent') {
// some block
sh 'mvn compile'
}
dir('common') {
sh 'mvn clean install deploy'
}
dir('config-service') {
sh 'mvn clean install'
}
dir('discovery-service') {
sh 'mvn compile'
}
dir('gateway-service') {
sh 'mvn compile'
}
dir('users') {
sh 'mvn compile'
}
dir('ideas') {
// some block
sh 'mvn compile'
}
stage ( 'install' ) {
// dir('config-service') {
// sh 'mvn clean install'
// }
dir ( 'parent') {
withMaven (){ // () uses global Jenkins defaults
sh "mvn clean install"
}
}
}
stage ('image'){
dir ('config-service') {
//withDockerRegistry(credentialsId: 'nexus-admin', url: 'http://save.worscipe.com:8080') {}
docker.withRegistry('https://save.worscipe.com:8080', 'nexus-admin') {
def app = docker.build "bright/config-service"
app.push()
}
}
}
stage ('deploy'){
// TODO https://github.com/jenkinsci/kubernetes-cd-plugin
kubernetesDeploy(kubeconfigId: 'kubeconfig-credentials-id', // REQUIRED
configs: '<ant-glob-pattern-for-resource-config-paths>', // REQUIRED
enableConfigSubstitution: false,
secretNamespace: '<secret-namespace>',
secretName: '<secret-name>',
dockerCredentials: [
[credentialsId: '<credentials-id-for-docker-hub>'],
[credentialsId: '<credentials-id-for-other-private-registry>', url: '<registry-url>'],
]
){
echo "kubernetesDeploy"
}
}
}