-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathJenkinsfile
More file actions
85 lines (75 loc) · 2.17 KB
/
Jenkinsfile
File metadata and controls
85 lines (75 loc) · 2.17 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
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
pipeline {
agent any
environment {
ARTIFACTORY_URL="http://172.31.32.31:8082/artifactory"
ARTIFACTORY_ID="artifactory-1"
ARTIFACTORY_CREDS="jfrog-creds"
}
stages{
stage("Build Code"){
steps {
script {
sh '''
mvn install
myver="\$(grep -i version pom.xml |head -2 |tail -1|cut -d">" -f2|cut -d"<" -f1)"
mv target/*.war target/myApp-v.\$myver-release-\${BUILD_NUMBER}.war
'''
}
}
}
stage("runing Unit Tests"){
steps {
script {
sh "mvn test"
}
}
}
stage("Code Analysis"){
environment {
def sonarHome = tool name: 'sonarscanner-4.7'
}
steps {
withSonarQubeEnv('mysonarserver') {
sh "${sonarHome}/bin/sonar-scanner -Dproject.settings=./myjavaapp.properties"
}
sleep time: 30000, unit: 'MILLISECONDS'
script {
def qg = waitForQualityGate()
if (qg.status != 'OK') {
error "Pipeline aborted due to quality gate failure: ${qg.status}"
}
}
}
}
stage ('Artifactory configuration') {
steps {
rtServer (
id: "${ARTIFACTORY_ID}",
url: "${ARTIFACTORY_URL}",
credentialsId: "${ARTIFACTORY_CREDS}"
)
}
}
stage ('Upload Artifacts') {
steps {
rtUpload (
// Obtain an Artifactory server instance, defined in Jenkins --> Manage Jenkins --> Configure System:
serverId: "artifactory-1",
spec: """{
"files": [
{
"pattern": "target/*.war",
"target": "example-repo-local/venki/"
}
]
}"""
)
}
}
}
post {
always {
cleanWs()
}
}
}