-
Notifications
You must be signed in to change notification settings - Fork 259
/
Copy pathJenkinsfile
110 lines (104 loc) · 3.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
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
def registry = 'https://valaxy05.jfrog.io'
def imageName = 'valaxy05.jfrog.io/valaxy-docker-local/ttrend'
def version = '2.1.4'
pipeline {
agent {
node {
label 'maven'
}
}
environment {
PATH = "/opt/apache-maven-3.9.2/bin:$PATH"
}
stages {
stage("build"){
steps {
echo "----------- build started ----------"
sh 'mvn clean deploy -Dmaven.test.skip=true'
echo "----------- build complted ----------"
}
}
stage("test"){
steps{
echo "----------- unit test started ----------"
sh 'mvn surefire-report:report'
echo "----------- unit test Complted ----------"
}
}
stage('SonarQube analysis') {
environment {
scannerHome = tool 'valaxy-sonar-scanner'
}
steps{
withSonarQubeEnv('valaxy-sonarqube-server') { // If you have configured more than one global server connection, you can specify its name
sh "${scannerHome}/bin/sonar-scanner"
}
}
}
stage("Quality Gate"){
steps {
script {
timeout(time: 1, unit: 'HOURS') { // Just in case something goes wrong, pipeline will be killed after a timeout
def qg = waitForQualityGate() // Reuse taskId previously collected by withSonarQubeEnv
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
}
stage("Jar Publish") {
steps {
script {
echo '<--------------- Jar Publish Started --------------->'
def server = Artifactory.newServer url:registry+"/artifactory" , credentialsId:"artfiact-cred"
def properties = "buildid=${env.BUILD_ID},commitid=${GIT_COMMIT}";
def uploadSpec = """{
"files": [
{
"pattern": "jarstaging/(*)",
"target": "libs-release-local/{1}",
"flat": "false",
"props" : "${properties}",
"exclusions": [ "*.sha1", "*.md5"]
}
]
}"""
def buildInfo = server.upload(uploadSpec)
buildInfo.env.collect()
server.publishBuildInfo(buildInfo)
echo '<--------------- Jar Publish Ended --------------->'
}
}
}
stage(" Docker Build ") {
steps {
script {
echo '<--------------- Docker Build Started --------------->'
app = docker.build(imageName+":"+version)
echo '<--------------- Docker Build Ends --------------->'
}
}
}
stage (" Docker Publish "){
steps {
script {
echo '<--------------- Docker Publish Started --------------->'
docker.withRegistry(registry, 'artfiact-cred'){
app.push()
}
echo '<--------------- Docker Publish Ended --------------->'
}
}
}
stage(" Deploy ") {
steps {
script {
echo '<--------------- Helm Deploy Started --------------->'
sh 'helm install ttrend ttrend-1.0.1.tgz'
echo '<--------------- Helm deploy Ends --------------->'
}
}
}
}
}