forked from jleetutorial/maven-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile0
48 lines (48 loc) · 1.48 KB
/
Jenkinsfile0
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
pipeline {
agent any
stages
{
stage('Build')
{
steps{
sh 'mvn clean package'
}
post {
success {
echo 'Now Archiving..'
archiveArtifacts artifacts: '**/target/*.war'
}
}
}
stage('Deploy to Production')
{
steps
{
slackSend (channel: "#Builds", color: '#4286f4', message: "Deploy Approval: '${env.JOB_NAME} [${env.BUILD_NUMBER}]'", attachments: "[{'fallback': 'You are unable to decide', 'callback_id': 'env.APPROVE_PROD', 'color': '#3AA3E3', 'attachment_type': 'default', 'actions': [ { 'name': 'approval', 'text': 'Approve', 'type': 'button', 'value': 'YES' }, { 'name': 'approval', 'text': 'Decline', 'type': 'button', 'value': 'NO' }]}]")
script
{
try
{
timeout(time:30, unit:'MINUTES')
{
if (env.APPROVE_PROD == 'YES')
{
env.PROD=true
echo "Deployment was approved, Proceeding with it..!"
}
else
{
env.PROD = false
echo "Deployment was not approved. aborting!"
}
}
} catch (error)
{
env.PROD = false
echo 'Timeout has been reached! Not going ahead with deployment.'
}
}
}
}
}
}