forked from dcos/dcos-ui
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathJenkinsfile
186 lines (167 loc) · 5.73 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[]
pipeline {
agent {
dockerfile {
args "--shm-size=1g"
}
}
environment {
JENKINS_VERSION = "yes"
NODE_PATH = "node_modules"
INSTALLER_URL= "https://downloads.dcos.io/dcos/testing/master/dcos_generate_config.sh"
}
options {
timeout(time: 4, unit: "HOURS")
disableConcurrentBuilds()
}
stages {
stage("Authorization") {
steps {
user_is_authorized(master_branches, "8b793652-f26a-422f-a9ba-0d1e47eb9d89", "#frontend-dev")
}
}
stage("Build") {
steps {
withCredentials([
usernamePassword(credentialsId: "a7ac7f84-64ea-4483-8e66-bb204484e58f", passwordVariable: "GIT_PASSWORD", usernameVariable: "GIT_USER")
]) {
// Clone the repository again with a full git clone
sh "rm -rf {.*,*} || ls -la && git clone https://\$GIT_USER:\[email protected]/dcos/dcos-ui.git ."
}
sh "git fetch"
sh "git checkout \"\$([ -z \"\$CHANGE_BRANCH\" ] && echo \$BRANCH_NAME || echo \$CHANGE_BRANCH )\""
sh "npm run validate-tests"
sh "npm --unsafe-perm ci"
sh "npm run build"
}
}
stage("Lint Commits") {
when {
expression {
!master_branches.contains(BRANCH_NAME)
}
}
steps {
sh 'npm run commitlint -- --from "${CHANGE_TARGET}"'
}
}
stage("Tests") {
parallel {
stage("Integration Test") {
environment {
REPORT_TO_DATADOG = master_branches.contains(BRANCH_NAME)
}
steps {
withCredentials([
string(credentialsId: '66c40969-a46d-470e-b8a2-6f04f2b3f2d5', variable: 'DATADOG_API_KEY'),
string(credentialsId: 'MpukWtJqTC3OUQ1aClsA', variable: 'DATADOG_APP_KEY'),
]) {
sh "./scripts/ci/createDatadogConfig.sh"
}
sh "npm run integration-tests"
}
post {
always {
archiveArtifacts "cypress/**/*"
// We currently want flaky test runs be marked as success
// 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"
]
]) {
retry(3) {
sh "dcos-system-test-driver -j1 -v ./system-tests/driver-config/jenkins.sh"
}
}
}
post {
always {
archiveArtifacts "results/**/*"
junit "results/results.xml"
}
}
}
}
}
stage("Semantic Release") {
steps {
withCredentials([
string(credentialsId: "d146870f-03b0-4f6a-ab70-1d09757a51fc", variable: "GH_TOKEN"), // semantic-release
string(credentialsId: "sentry_io_token", variable: "SENTRY_AUTH_TOKEN"), // upload-build
string(credentialsId: "3f0dbb48-de33-431f-b91c-2366d2f0e1cf",variable: "AWS_ACCESS_KEY_ID"), // upload-build
string(credentialsId: "f585ec9a-3c38-4f67-8bdb-79e5d4761937",variable: "AWS_SECRET_ACCESS_KEY"), // upload-build
usernamePassword(credentialsId: "a7ac7f84-64ea-4483-8e66-bb204484e58f", passwordVariable: "GIT_PASSWORD", usernameVariable: "GIT_USER"), // update-dcos-repo
usernamePassword(credentialsId: "6c147571-7145-410a-bf9c-4eec462fbe02", passwordVariable: "JIRA_PASS", usernameVariable: "JIRA_USER") // semantic-release-jira
]) {
sh "npx semantic-release"
}
}
}
stage("Publish Universe") {
when {
expression {
master_branches.contains(BRANCH_NAME)
}
}
steps {
withCredentials([
string(credentialsId: "1ddc25d8-0873-4b6f-949a-ae803b074e7a", variable: "AWS_ACCESS_KEY_ID"),
string(credentialsId: "875cfce9-90ca-4174-8720-816b4cb7f10f", variable: "AWS_SECRET_ACCESS_KEY"),
]) {
sh "git clone https://github.com/mesosphere/dcos-commons.git ../dcos-commons"
sh "tar czf release.tar.gz dist"
sh "S3_BUCKET='dcos-ui-universe' S3_DIR_PATH='oss' S3_DIR_NAME='latest' ../dcos-commons/tools/build_package.sh 'dcos-ui' ./ -a ./release.tar.gz aws"
}
}
}
stage("Run Enterprise Pipeline") {
when {
expression {
master_branches.contains(BRANCH_NAME)
}
}
steps {
build job: "frontend/dcos-ui-ee-pipeline/" + env.BRANCH_NAME.replaceAll("/", "%2F"), wait: false
}
}
}
post {
failure {
withCredentials([
string(credentialsId: "8b793652-f26a-422f-a9ba-0d1e47eb9d89", variable: "SLACK_TOKEN")
]) {
slackSend (
channel: "#frontend-ci-status",
color: "danger",
message: "FAILED\nBranch: ${env.CHANGE_BRANCH}\nJob: <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>",
teamDomain: "mesosphere",
token: "${env.SLACK_TOKEN}",
)
}
}
unstable {
withCredentials([
string(credentialsId: "8b793652-f26a-422f-a9ba-0d1e47eb9d89", variable: "SLACK_TOKEN")
]) {
slackSend (
channel: "#frontend-ci-status",
color: "warning",
message: "UNSTABLE\nBranch: ${env.CHANGE_BRANCH}\nJob: <${env.RUN_DISPLAY_URL}|${env.JOB_NAME} [${env.BUILD_NUMBER}]>",
teamDomain: "mesosphere",
token: "${env.SLACK_TOKEN}",
)
}
}
}
}