forked from dcos/dcos-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile
186 lines (158 loc) · 4.54 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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
#!/usr/bin/env groovy
@Library('sec_ci_libs@v2-latest') _
def master_branches = ["master", ] as String[]
def SEMVER_REGEX = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(-(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(\.(0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*)?(\+[0-9a-zA-Z-]+(\.[0-9a-zA-Z-]+)*)?/
pipeline {
agent {
dockerfile {
args '--shm-size=2g'
}
}
environment {
JENKINS_VERSION = 'yes'
NODE_PATH = 'node_modules'
INSTALLER_URL= 'https://downloads.dcos.io/dcos/testing/master/dcos_generate_config.sh'
}
options {
timeout(time: 3, unit: 'HOURS')
}
stages {
stage('Authorization') {
steps {
user_is_authorized(master_branches, '8b793652-f26a-422f-a9ba-0d1e47eb9d89', '#frontend-dev')
}
}
stage('Initialization') {
steps {
ansiColor('xterm') {
retry(2) {
sh '''npm --unsafe-perm install'''
}
sh '''npm run scaffold'''
}
}
}
stage('Lint') {
steps {
ansiColor('xterm') {
sh '''npm run lint'''
}
}
}
stage('Unit Test') {
steps {
ansiColor('xterm') {
sh '''npm run test -- --maxWorkers=2'''
}
}
}
stage('Build') {
steps {
ansiColor('xterm') {
sh '''npm run build-assets'''
}
}
post {
always {
stash includes: 'dist/*', name: 'dist'
}
}
}
stage('Integration Test') {
steps {
// Run a simple webserver serving the dist folder statically
// before we run the cypress tests
writeFile file: 'integration-tests.sh', text: [
'export PATH=`pwd`/node_modules/.bin:$PATH',
'http-server -p 4200 dist&',
'SERVER_PID=$!',
'./scripts/ci/run-integration-tests',
'RET=$?',
'echo "cypress exit status: ${RET}"',
'sleep 10',
'echo "kill server"',
'kill $SERVER_PID',
'exit $RET'
].join('\n')
unstash 'dist'
ansiColor('xterm') {
retry(2) {
sh '''bash integration-tests.sh'''
}
}
}
post {
always {
archiveArtifacts 'cypress/**/*'
junit 'cypress/results.xml'
}
}
}
stage('System Test') {
steps {
withCredentials([
[
$class: 'AmazonWebServicesCredentialsBinding',
credentialsId: 'f40eebe0-f9aa-4336-b460-b2c4d7876fde',
accessKeyVariable: 'AWS_ACCESS_KEY_ID',
secretKeyVariable: 'AWS_SECRET_ACCESS_KEY'
]
]) {
unstash 'dist'
ansiColor('xterm') {
retry(2) {
sh '''dcos-system-test-driver -j1 -v ./system-tests/driver-config/jenkins.sh'''
}
}
}
}
post {
always {
archiveArtifacts 'results/**/*'
junit 'results/results.xml'
}
}
}
// when env.BRANCH_NAME == 'master', we will update the mesosphere:dcos-ui/latest branch
// when env.BRANCH_NAME =~ /(tag-name-regex)/, we will open a release PR against dcos/dcos
stage('Upload Build') {
when {
expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME =~ SEMVER_REGEX }
}
steps {
withCredentials([
string(credentialsId: '3f0dbb48-de33-431f-b91c-2366d2f0e1cf',variable: 'AWS_ACCESS_KEY_ID'),
string(credentialsId: 'f585ec9a-3c38-4f67-8bdb-79e5d4761937',variable: 'AWS_SECRET_ACCESS_KEY')
]) {
sh "BRANCH_NAME=${env.BRANCH_NAME} ./scripts/ci/upload-build"
}
}
post {
always {
archiveArtifacts 'buildinfo.json'
}
}
}
stage('Update Github'){
when {
expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME =~ SEMVER_REGEX }
}
steps {
withCredentials([
usernamePassword(credentialsId: 'a7ac7f84-64ea-4483-8e66-bb204484e58f', passwordVariable: 'GIT_PASSWORD', usernameVariable: 'GIT_USER')
]) {
sh "GIT_PASSWORD=${GIT_PASSWORD} GIT_USER=${GIT_USER} ./scripts/ci/update-github"
}
}
}
// trigger the other job to update the upstream reference
stage ('Trigger Enterprise Update') {
when {
expression { env.BRANCH_NAME == 'master' || env.BRANCH_NAME =~ SEMVER_REGEX }
}
steps {
build job: "frontend/dcos-ui-ee-release/${env.BRANCH_NAME}", parameters: [[$class: 'StringParameterValue', name: 'BRANCH_NAME', value: env.BRANCH_NAME]]
}
}
}
}