forked from kbsri86/First_repo
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsFile
72 lines (71 loc) · 3.14 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
def semanticVersion = "${env.BUILD_NUMBER}.0.0"
def packageName = "devops_pipeline_demo_${env.BUILD_NUMBER}"
def version = "${env.BUILD_NUMBER}.0"
pipeline {
agent any
tools {
maven 'Maven'
}
environment {
SCANNER_HOME = tool 'sonarScanner'
}
stages {
stage("Build") {
steps {
echo "Building..."
sh 'mvn clean install -DskipTests=true'
}
}
stage("SoftwareQuality") {
steps {
echo "Software Quality..."
sonarTest()
}
}
stage("Test") {
steps {
echo "Testing..."
sh "mvn test -Dpublish"
junit "**/target/surefire-reports/*.xml"
}
}
stage("Deploy") {
steps {
echo "Deploying.."
snDevOpsArtifact(artifactsPayload:"""{"artifacts": [
{"name": "demo1.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo1"},
{"name": "demo2.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo2"},
{"name": "demo3.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo3"},
{"name": "demo4.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo4"},
{"name": "demo5.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo5"}]}""")
}
}
stage("Prod") {
steps {
echo "Prod deploy..."
snDevOpsPackage(name: "${packageName}", artifactsPayload: """{"artifacts": [
{"name": "demo1.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo1"},
{"name": "demo2.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo2"},
{"name": "demo3.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo3"},
{"name": "demo4.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo4"},
{"name": "demo5.jar","version": "${version}","semanticVersion": "${semanticVersion}","repositoryName": "demo5"}]}""")
}
}
stage("Change") {
steps {
echo "Change..."
snDevOpsChange()
}
}
}
}
def sonarTest() {
withSonarQubeEnv('sonarQube_local') {
sh '${SCANNER_HOME}/bin/sonar-scanner -Dproject.settings=${SCANNER_HOME}/conf/qa-sonar-scanner.properties'
// sh '${SCANNER_HOME}/bin/sonar-scanner -Dproject.settings=${SCANNER_HOME}/conf/sonar-scanner.properties'
}
//withSonarQubeEnv('SonarQube_Cloud') {
// sh '${SCANNER_HOME}/bin/sonar-scanner -Dproject.settings=${SCANNER_HOME}/conf/sonar-scanner.properties '
//sh '${SCANNER_HOME}/bin/sonar-scanner -Dproject.settings=${SCANNER_HOME}/conf/qa-sonar-scanner-cloud.properties'
//}
}