forked from MetaiR/spring-mvc-quick-start-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
62 lines (61 loc) · 1.38 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
pipeline{
agent { label 'Jenkin-Agent' }
tools{
jdk 'Java17'
maven 'Maven3'
}
environment{
APP_NAME = "START-KIT"
RELEASE = "1.0.0"
DOCKER_USER = "ghalge"
DOCKER_PASS = 'dockerhub'
IMAGE_NAME = "${DOCKER_USER}" "/" "${APP_NAME}"
IMAGE_TAG = "${RELEASE}-${BUILDNUMBER}"
}
stages{
stage("Checking out from SCM"){
steps{
git changelog: false, credentialsId: 'github', poll: false, url: 'https://github.com/nikle45/spring-mvc-quick-start-kit'
}
}
stage("Bulid Application"){
steps{
sh 'mvn clean package'
}
}
stage("Test"){
steps{
sh 'mvn test'
}
}
stage("sonarqube Analysis"){
steps{
script{
withSonarQubeEnv(credentialsId: 'Jenkins-sonarqube-token') {
sh 'mvn sonar:sonar'
}
}
}
}
stage("Quality Gate"){
steps{
script{
waitForQualityGate abortPipeline: false, credentialsId: 'Jenkins-sonarqube-token'
}
}
}
stage("Build and push docker image "){
steps{
script{
docker.withRegistry('',DOCKER_PASS){
docker_image = docker.build "${IMAGE_NAME}"
}
docker.withRegistry('',DOCKER_PASS){
docker_image.push("${IMAGE_TAG}")
docker_image.push('latest')
}
}
}
}
}
}