-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
106 lines (106 loc) · 2.61 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
pipeline {
triggers {
githubPush()
pollSCM('H/15 * * * *')
}
parameters {
booleanParam(
name: 'CLEAN_WORKSPACE',
defaultValue: false,
description: 'Start with empty workspace'
)
}
agent {
kubernetes {
inheritFrom 'toolbox'
label 'pod'
containerTemplate(
name: 'buildbox',
image: 'node:10',
ttyEnabled: true,
command: 'cat'
)
}
}
stages {
stage('Init') {
steps {
script {
if (params.CLEAN_WORKSPACE) {
echo "Wiping out workspace"
deleteDir()
} else {
echo 'Skipping cleanup due to user setting'
}
}
}
}
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
environment {
CONTEXT_PATH = "${params.INGRESS_CONTEXT}"
APPLICATION_REPOSITORY = "${gitscm.remote}"
APPLICATION_BRANCH = "${gitscm.branch}"
}
steps {
container('toolbox') {
script {
dir ('.hub') {
hub.elaborate(manifest: 'hub.yaml', state: params.APP_STATE_FILE)
final outputs = hub.explain(manifest: 'hub.yaml', state: params.APP_STATE_FILE).stackOutputs
appBucket = outputs['application.bucket'] as String
appPath = outputs['application.path'] as String
appTheme = outputs['application.theme'] as String
if (appTheme?.trim()) {
println "Application theme is defined as \"${appTheme}\""
env.APPLICATION_THEME = appTheme.trim()
}
}
}
}
container('buildbox') {
sh script: 'npm install'
sh script: 'npm run junit:test'
sh script: 'npm run build'
}
}
}
stage('Lint') {
steps {
container('buildbox') {
script {
try {
sh script: 'npm run junit:lint'
} catch (err) {
currentBuild.result = 'UNSTABLE'
currentBuild.description = 'Found lint violations'
}
}
}
}
}
stage('Deploy Application') {
steps {
container('toolbox') {
script {
withAWS(role:params.AWS_TRUST_ROLE) {
sh script: "aws s3 sync --delete dist/ s3://${appBucket}/${appPath}"
}
}
}
}
}
}
post {
always {
junit testResults: './tests-*.xml', allowEmptyResults: true
}
changed {
slackSend color: slack.buildColor, message: slack.buildReport
}
}
}