-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
48 lines (43 loc) · 1.49 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
pipeline{
agent any
environment{
VERSION = "${env.BUILD_ID}"
}
stages{
stage("Sonar Quality Check"){
agent{
docker{
image 'openjdk:11'
}
}
steps{
script{
withSonarQubeEnv(credentialsid: 'sonar-token'){
sh 'chmod +x gradlew'
sh './gradlew sonarqube'
}
timeout(time: 1, unit: 'HOURS'){
def qg = waitForQualityGate()
if (qg.status != 'OK'){
error 'Pipeline stopped due to quality gate failure: ${qg.status}'
}
}
}
}
}
stage("Docker image build & push"){
steps{
script{
withCredentials([string(credentialsId: 'docker_password', variable: 'docker_password')]) {
sh '''
docker build -t 36.128.214.178:8083/brivan:${VERSION} .
docker login -u admin -p $docker_password 36.128.214.178:8083
docker push 36.128.214.178:8083/brivan:${VERSION}
docker rmi 36.128.214.178:8083/brivan:${VERSION}
'''
}
}
}
}
}
}