forked from MithunTechnologiesDevOps/maven-web-application
-
Notifications
You must be signed in to change notification settings - Fork 0
/
JenkinsfileAugBacth2022
84 lines (65 loc) · 2.13 KB
/
JenkinsfileAugBacth2022
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
@Library('sharedlibsmss') _
node{
try{
sendSlackNotifications('STARTED')
def mavenHome = tool name: 'maven3.8.6'
echo "The JobName is: ${env.JOB_NAME}"
echo "The node name is: ${env.NODE_NAME}"
echo "The build number is: ${env.BUILD_NUMBER}"
properties([buildDiscarder(logRotator(artifactDaysToKeepStr: '', artifactNumToKeepStr: '5', daysToKeepStr: '', numToKeepStr: '5')), [$class: 'JobLocalConfiguration', changeReasonComment: ''], pipelineTriggers([pollSCM('* * * * *')])])
stage('CheckOutCode'){
git branch: 'development', credentialsId: '1ed3c65b-4e6a-46ae-9e15-56aab257dac5', url: 'https://github.com/MithunTechnologiesDevOps/maven-web-application.git'
}
stage('Build'){
sh "${mavenHome}/bin/mvn package"
}
/*
stage('ExecuteSoanrQubeReport')
{
sh "${mavenHome}/bin/mvn clean sonar:sonar"
}
stage('UploadArtifactsIntoNexus')
{
sh "${mavenHome}/bin/mvn clean deploy"
}
stage('DeployAppIntoTomcatServer'){
sshagent(['ed3c425a-5ed2-4384-99c1-12cc22911ec4']) {
sh "scp -o StrictHostKeyChecking=no target/maven-web-application.war ec2-user@172.31.42.12:/opt/apache-tomcat-9.0.67/webapps/"
}
}
*/
}//try closing
catch(e){
currentBuild.result="FAILURE"
throw e
}//catch closing
finally{
sendSlackNotifications(currentBuild.result)
}
} //Node closing
/*
//Code Snippet for sending slack notifications.
def slackNotifications(String buildStatus = 'STARTED') {
// build status of null means successful
buildStatus = buildStatus ?: 'SUCCESS'
//buildStatus = buildStatus ? "SUCCESS":"FAILURE"
// 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') {
colorName = 'ORANGE'
colorCode = '#FFA500'
} else if (buildStatus == 'SUCCESS') {
colorName = 'GREEN'
colorCode = '#00FF00'
} else {
colorName = 'RED'
colorCode = '#FF0000'
}
// Send notifications
slackSend (color: colorCode, message: summary, channel: "#walmart")
}
*/