-
Notifications
You must be signed in to change notification settings - Fork 11
/
Jenkinsfile
121 lines (105 loc) · 2.98 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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
pipeline {
agent any
options {
timeout(time: 20, unit: 'MINUTES')
}
stages {
stage('Checkout') {
steps {
checkout scm
}
}
stage('Build') {
steps {
runCompose("-f docker-compose.yml -f compose/test.yml -f compose/robot.yml", "build --pull")
}
}
stage('Quality') {
parallel {
stage('Lint') {
steps {
runCompose("-f compose/test.yml", "run lint")
}
}
stage('Audit') {
steps {
sleep 1
runCompose("-f compose/test.yml", "run audit")
}
}
}
}
stage('Unit Test') {
parallel {
stage('Mocha') {
steps {
runCompose("-f compose/test.yml", "run mocha")
}
}
stage('Jest') {
steps {
sleep 1
runCompose("-f compose/test.yml", "run jest")
}
}
}
}
stage('Robot Test') {
steps {
runCompose("-f docker-compose.yml -f compose/test.yml -f compose/robot.yml", "down -v")
runCompose("-f compose/robot.yml", "run robot.backend ./wait-for robot.db:5432 -- npm run db:seed:all")
runCompose("-f compose/robot.yml", "run robot")
}
post {
always {
step([$class: 'ArtifactArchiver', artifacts: 'results/robot/log.html, results/robot/selenium-*.png'])
step([$class: 'RobotPublisher',
disableArchiveOutput: false,
logFileName: 'results/robot/log.html',
onlyCritical: true,
otherFiles: '',
outputFileName: 'results/robot/output.xml',
outputPath: '.',
passThreshold: 90,
reportFileName: 'results/robot/report.html',
unstableThreshold: 100]);
}
}
}
stage('Deploy') {
steps {
runCompose("-f docker-compose.yml -f compose/test.yml -f compose/robot.yml", "down -v")
runDeploy()
}
}
}
/*
post {
always {
// notifyBuild(currentBuild.result)
}
}
*/
}
def runCompose(composeFiles = "", operation = "build", setEnvironment = "") {
sh "${setEnvironment} docker-compose -p designsystem --project-directory . ${composeFiles} ${operation}"
}
def runDeploy() {
sh "bin/deploy.sh"
}
def notifyBuild(String buildStatus = 'STARTED') {
buildStatus = buildStatus ?: 'SUCCESS'
def colorCode = '#FF9FA1'
def subject = "${buildStatus}: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]'"
def summary = "${subject} (${env.BUILD_URL})"
def details = """<p>STARTED: Job '${env.JOB_NAME} [${env.BUILD_NUMBER}]':</p>
<p>Check console output at "<a href='${env.BUILD_URL}'>${env.JOB_NAME} [${env.BUILD_NUMBER}]</a>"</p>"""
if (buildStatus == 'STARTED') {
colorCode = '#D4DADF'
} else if (buildStatus == 'SUCCESS') {
colorCode = '#BDFFC3'
} else {
colorCode = '#FF9FA1'
}
slackSend(teamDomain: "", token: "", color: colorCode, message: summary)
}