forked from bcreddydevops/springboot-maven-course-micro-svc
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjenkinsfile-working
More file actions
50 lines (48 loc) · 1.47 KB
/
Copy pathjenkinsfile-working
File metadata and controls
50 lines (48 loc) · 1.47 KB
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
pipeline{
agent any
tools{
maven 'maven'
}
stages{
stage('checkout the code'){
steps{
git url:'https://github.com/jagdishmodi/springboot-maven-course-micro-svc.git', branch: 'master'
}
}
stage('build the code'){
steps{
sh 'mvn clean package'
}
}
stage("sonar quality check"){
steps{
script{
withSonarQubeEnv(installationName: 'sonarqube', credentialsId: 'jenkins-sonar-token') {
sh 'mvn sonar:sonar '
}
timeout(time: 1, unit: 'HOURS') {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage('Docker Build') {
agent any
steps {
sh 'docker build -t jagdish1983/spring-petclinic:latest .'
}
}
stage('Docker Push') {
agent any
steps {
withCredentials([usernamePassword(credentialsId: 'dockerhub', passwordVariable: 'dockerHubPassword', usernameVariable: 'dockerHubUser')]) {
sh "docker login -u ${env.dockerHubUser} -p ${env.dockerHubPassword}"
sh 'docker push jagdish1983/spring-petclinic:latest'
}
}
}
}
}