forked from atinsingh/devopsjava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile
More file actions
99 lines (90 loc) · 2.47 KB
/
Jenkinsfile
File metadata and controls
99 lines (90 loc) · 2.47 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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
pipeline {
agent any
tools{
maven 'm3'
jdk 'jdk8'
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Compile') {
steps {
sh 'mvn compile'
}
}
stage('SonarQube analysis') {
steps {
withSonarQubeEnv(credentialsId: 'sonarqube',installationName:'sonarqube') {
sh 'mvn org.sonarsource.scanner.maven:sonar-maven-plugin:3.7.0.1746:sonar'
}
}
}
// stage("Quality Gate") {
// steps {
// timeout(time: 2, unit: 'MINUTES') {
// // Parameter indicates whether to set pipeline to UNSTABLE if Quality Gate fails
// // true = set pipeline to UNSTABLE, false = don't
// waitForQualityGate abortPipeline: true
// }
// }
// }
stage('Test') {
steps {
sh 'mvn test'
}
}
stage('Package') {
steps {
sh 'mvn package'
}
}
stage ('Artifactory configuration') {
steps {
rtServer (
id: "art1",
url: "http://3.16.10.158/artifactory",
credentialsId: "artifactory"
)
rtMavenDeployer (
id: "MAVEN_DEPLOYER",
serverId: "art1",
releaseRepo: "libs-release-local",
snapshotRepo: "libs-snapshot-local"
)
rtMavenResolver (
id: "MAVEN_RESOLVER",
serverId: "art1",
releaseRepo: "libs-release",
snapshotRepo: "libs-snapshot"
)
}
}
stage ('Exec Maven') {
steps {
rtMavenRun (
tool: 'm3', // Tool name from Jenkins configuration
pom: 'pom.xml',
goals: 'install',
deployerId: "MAVEN_DEPLOYER",
resolverId: "MAVEN_RESOLVER"
)
}
}
stage ('Publish build info') {
steps {
rtPublishBuildInfo (
serverId: "art1"
)
}
}
}
post {
always {
junit '**/*.xml'
slackSend channel: 'devops_sept_2020', color: 'red', message: "BUILD FAILD - $JOB_NAME - $BUILD_ID", teamDomain: 'pragraconsulting2020', tokenCredentialId: 'slack'
}
}
}