-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
47 lines (38 loc) · 1.39 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
library(
identifier: '[email protected]',
retriever: modernSCM([$class: 'GitSCMSource',
remote: 'https://github.com/SmartColumbusOS/pipeline-lib',
credentialsId: 'jenkins-github-user'])
)
properties([
pipelineTriggers([scos.dailyBuildTrigger()]),
])
def doStageIf = scos.&doStageIf
def doStageIfRelease = doStageIf.curry(scos.changeset.isRelease)
def doStageUnlessRelease = doStageIf.curry(!scos.changeset.isRelease)
def doStageIfPromoted = doStageIf.curry(scos.changeset.isMaster)
node ('infrastructure') {
ansiColor('xterm') {
scos.doCheckoutStage()
doStageUnlessRelease('Deploy to Dev') {
deployTo(environment: 'dev')
}
doStageIfPromoted('Deploy to Staging') {
deployTo(environment: 'staging')
scos.applyAndPushGitHubTag('staging')
}
doStageIfRelease('Deploy to Production') {
deployTo(environment: 'prod')
scos.applyAndPushGitHubTag('prod')
}
}
}
def deployTo(params = [:]) {
def environment = params.get('environment')
def extraVars = params.get('extraVars', [:])
if (environment == null) throw new IllegalArgumentException("environment must be specified")
def terraform = scos.terraform(environment)
terraform.init()
terraform.plan(terraform.defaultVarFile, extraVars)
terraform.apply()
}