-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile-deploy-production
70 lines (61 loc) · 2.6 KB
/
Jenkinsfile-deploy-production
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
#!groovy
SELECTED_DEPLOYMENT_OPTION = "latest"
SPECIFIC_VERSION = ""
stage ('Approve deploy?') {
timeout(time: 5, unit: 'MINUTES') {
SELECTED_DEPLOYMENT_OPTION =
input message: 'Deploy to production?', parameters: [[$class: 'ChoiceParameterDefinition',
choices: 'latest\nspecific',
description: 'The latest or a specific manually entered version',
name: '']]
if (SELECTED_DEPLOYMENT_OPTION == "specific") {
SPECIFIC_VERSION =
input message: 'Enter version?', parameters: [[$class: 'StringParameterDefinition',
defaultValue: '',
description: 'Specific version to deploy',
name: '']]
}
}
}
// one at a time!
lock('lock-deploy-production') {
stage('Deploy production') {
node {
timeout(time: 5, unit: 'MINUTES') {
checkout scm
stash excludes: 'build/', includes: '**', name: 'source'
if (SELECTED_DEPLOYMENT_OPTION == "latest") {
sh '''TAG=`git describe --abbrev=0`
./gradlew deployToProduction -PrepoId=releases -PartifactVersion=$TAG'''
} else if (SELECTED_DEPLOYMENT_OPTION == "specific") {
echo "Deploying specific version: ${SPECIFIC_VERSION}"
sh './gradlew deployToProduction -PrepoId=releases -PartifactVersion=' + SPECIFIC_VERSION
} else {
throw new RuntimeException("Invalid deployment option selected: ${SELECTED_DEPLOYMENT_OPTION}")
}
}
}
}
}
stage ('Health check') {
timeout(time: 5, unit: 'MINUTES') {
parallel 'prodServer1': {
node {
retry(5) {
unstash 'source'
sh 'chmod 755 gradlew'
sh 'SPRING_PROFILES_ACTIVE=online,production,prodServer1 ./gradlew smokeTest'
}
}
}, 'prodServer2': {
node {
retry(5) {
unstash 'source'
sh 'chmod 755 gradlew'
sh 'SPRING_PROFILES_ACTIVE=online,production,prodServer2 ./gradlew smokeTest'
}
}
}
deleteDir() // Wipe out the workspace
}
}