-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jenkinsfile
69 lines (69 loc) · 3.4 KB
/
Jenkinsfile
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
pipeline {
agent {
docker {
image 'maven:3.5.2-jdk-8'
}
}
environment {
stagingPostgresDbUrl = credentials('STAGINGPROPERTYREGISTRYDBURL')
fallBackPostgresDbUrl = credentials('PRODUCTIONPROPERTYREGISTRYDBURL')
productionPostgresDbUrl = credentials('PRODUCTIONPROPERTYREGISTRYDBURL')
postgresDBUserName = credentials('POSTGRESDBUSERNAME')
postgresDBPassword = credentials('POSTGRESDBPASSWORD')
tomcatCredentials = credentials('TOMCATCREDENTIALS')
stagingHost = credentials('STAGINGHOST')
fallbackHost = credentials('FALLBACKHOST')
productionHost = credentials('PRODUCTIONHOST')
smtpHost = credentials('SMTPHOST')
ampt2dEmailId = credentials('AMPT2DEMAILID')
}
parameters {
booleanParam(name: 'DeployToStaging' , defaultValue: false , description: '')
booleanParam(name: 'DeployToProduction' , defaultValue: false , description: '')
}
stages {
stage('Default Build pointing to Staging DB') {
steps {
sh "mvn clean package -DskipTests -DbuildDirectory=staging/target -Dampt2d-property-registry-db.url=${stagingPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmailId}"
}
}
stage('Build For FallBack And Production') {
when {
expression {
params.DeployToProduction == true
}
}
steps {
echo 'Build pointing to FallBack DB'
sh "mvn clean package -DskipTests -DbuildDirectory=fallback/target -Dampt2d-property-registry-db.url=${fallBackPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmailId}"
echo 'Build pointing to Production DB'
sh "mvn clean package -DskipTests -DbuildDirectory=production/target -Dampt2d-property-registry-db.url=${productionPostgresDbUrl} -Dampt2d-property-registry-db.username=${postgresDBUserName} -Dampt2d-property-registry-db.password=${postgresDBPassword} -Dsmtp-host=${smtpHost} -Damp-t2d-email-id=${ampt2dEmailId}"
}
}
stage('Deploy To Staging') {
when {
expression {
params.DeployToStaging == true
}
}
steps {
echo 'Deploying to Staging'
sh "curl --upload-file staging/target/amp-t2d-property-registry-*.war 'http://'${tomcatCredentials}'@'${stagingHost}':8080/manager/text/deploy?path=/dev/registry&update=true' | grep 'OK - Deployed application at context path '"
}
}
stage('Deploy To FallBack And Production') {
when {
expression {
params.DeployToProduction == true
}
}
steps {
echo 'Deploying to Fallback'
sh "curl --upload-file fallback/target/amp-t2d-property-registry-*.war 'http://'${tomcatCredentials}'@'${fallbackHost}':8080/manager/text/deploy?path=/registry&update=true' | grep 'OK - Deployed application at context path '"
echo 'Deploying to Production'
sh "curl --upload-file production/target/amp-t2d-property-registry-*.war 'http://'${tomcatCredentials}'@'${productionHost}':8080/manager/text/deploy?path=/registry&update=true' | grep 'OK - Deployed application at context path '"
archiveArtifacts artifacts: 'production/target/amp-t2d-property-registry-*.war' , fingerprint: true
}
}
}
}