forked from naresh26git/multi-branch
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
55 lines (55 loc) · 1.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
pipeline {
agent any
tools {
maven 'maven3'
}
stages {
stage ('Build') {
steps {
script{
def mvnHome = tool name: 'maven3', type: 'maven'
sh "mvn package"
//sh 'mv target/onlinebookstore*.war target/newbook.war'
}
}
}
stage ('SonarQube'){
steps{
script{
def mvnHome = tool name: 'maven3', type: 'maven'
withSonarQubeEnv('sonar-pro') {
sh "${mvnHome}/bin/mvn sonar:sonar"
}
}
}
}
stage('Docker Build') {
steps{
script{
sh 'docker build -t harikrishnan586/multi:v1 .'
//sh 'docker images'
}
}
}
stage('Docker push'){
steps{
script{
withCredentials([string(credentialsId: 'dockerPass', variable: 'dockerPassword')]) {
sh "docker login -u harikrishnan586 -p ${dockerPassword}"
sh 'docker push harikrishnan586/multi:v1'
sh 'docker rmi harikrishnan586/multi:v1'
}
}
}
}
stage('Deploy on k8s') {
steps {
script{
withKubeCredentials(kubectlCredentials: [[ credentialsId: 'k8s', namespace: 'ms' ]]) {
sh 'kubectl apply -f kube.yaml'
}
}
}
}
}
}