forked from MithunTechnologiesDevOps/maven-web-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsfileMarchdp
103 lines (83 loc) · 2.1 KB
/
JenkinsfileMarchdp
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
pipeline{
agent any
parameters {
choice choices: ['master', 'development', 'stage', 'uat'], description: 'Select the Branch Name', name: 'BranchName'
string defaultValue: 'Mithun Software Solutions', name: 'PersonName'
}
tools{
maven 'maven3.9.1'
}
options {
buildDiscarder logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5')
timestamps()
}
triggers {
pollSCM('* * * * * ')
}
stages{
stage('CheckoutCode'){
steps{
sendSlackNotifications('STARTED')
git branch: "${params.BranchName}", credentialsId: 'aaa8e2c0-226a-40ba-85eb-259762d67c15', url: 'https://github.com/MithunTechnologiesDevOps/maven-web-application.git'
}
}
stage('Build'){
steps{
sh "mvn clean package"
}
}
/*
//Execute SonarQube Report
stage('ExecuteSonarQubeReport'){
steps{
sh "mvn clean sonar:sonar"
}
}
//UploadArtifactsIntoNexus
stage('ArtifactsIntoNexus'){
steps{
sh "mvn clean deploy"
}
}
//DeployApplication into TOmcat Server
stage('DeploApp'){
steps{
sshagent(['dd085870-ab36-4a86-9f5b-a915e179d45d']) {
sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war [email protected]:/opt/apache-tomcat-9.0.73/webapps/"
}
}
}
*/
}//stages closing
post {
success {
sendSlackNotifications(currentBuild.result)
}
failure {
sendSlackNotifications(currentBuild.result)
}
}
}//pipeline closing
//Function for slack notifications
def sendSlackNotifications(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
// Default values
def colorName = 'RED'
def colorCode = '#FF0000'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
// Override default values based on build status
if (buildStatus == 'STARTED') {
color = 'YELLOW'
colorCode = '#FFFF00'
} else if (buildStatus == 'SUCCESS') {
colorName = 'GREEN'
colorCode = '#00FF00'
} else {
colorName = 'RED'
colorCode = '#FF0000'
}
// Send notifications
slackSend (color: colorCode, message: summary, channel: '#citibank')
}