-
Notifications
You must be signed in to change notification settings - Fork 14
/
Copy pathJenkinsfile
80 lines (73 loc) · 1.71 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
pipeline {
environment {
registry = "sample/department"
registryCredential = 'dockerhub_id'
dockerImage = ''
}
agent {
docker {
image 'maven:3-alpine'
args '-v /root/.m2:/root/.m2'
}
}
stages {
stage('Clone repository') {
steps {
/* Clone our repository */
checkout scm
}
}
stage('Build') {
steps {
sh 'mvn -B -DskipTests clean package'
}
}
stage('Test') {
steps {
sh 'mvn test'
}
post {
always {
junit 'target/surefire-reports/*.xml'
}
}
}
stage('Validate the Jar Version') {
steps {
sh './ci-build/deliver.sh'
}
post {
always {
archiveArtifacts artifacts: 'target/*.jar', fingerprint: true
}
}
}
}
}
stage('Build image') {
node {
withEnv([
'SERVICE=department',
'TAG=1.1'
]){
/* Build the docker image */
sh 'echo "clear <none docker images>"'
sh "./ci-build/clear-images.sh"
sh "docker build --no-cache -t ${SERVICE}:${TAG} ."
}
}
}
stage('Deploy to k8s') {
node {
withEnv([
'SERVICE=department',
'NAMESPACE=default',
'TAG=1.1'
]){
/* Apply all manifest files */
sh "pwd"
sh "cat /root/.kube/ca.crt"
sh "./deployment/deploy.sh"
}
}
}