forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJenkinsfile.docker-smoke
More file actions
143 lines (128 loc) · 3.92 KB
/
Copy pathJenkinsfile.docker-smoke
File metadata and controls
143 lines (128 loc) · 3.92 KB
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
#!/usr/bin/env groovy
/*
* Copyright (C) 2026 - present Instructure, Inc.
*
* This file is part of Canvas.
*
* Canvas is free software: you can redistribute it and/or modify it under
* the terms of the GNU Affero General Public License as published by the Free
* Software Foundation, version 3 of the License.
*
* Canvas is distributed in the hope that it will be useful, but WITHOUT ANY
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
* A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
* details.
*
* You should have received a copy of the GNU Affero General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
library "canvas-builds-library@${env.CANVAS_BUILDS_REFSPEC}"
loadLocalLibrary('local-lib', 'build/new-jenkins/library')
pipeline {
agent {
label nodeLabel()
}
options {
ansiColor('xterm')
timeout(time: 22)
timestamps()
}
environment {
JENKINS = 'true'
DOCKER = 'true'
}
stages {
stage('Setup') {
steps {
// always pull from gerrit refspec to test the changed docker dev code
checkoutFromGit(gerritProjectUrl('canvas-lms'), refspec: env.GERRIT_REFSPEC, depth: 1)
sh '''#!/bin/bash
cat <<EOF > docker-compose.local.jenkins.yml
version: '2.3'
services:
web:
environment:
CANVAS_LMS_ADMIN_EMAIL: jenkins@fake.com
CANVAS_LMS_ADMIN_PASSWORD: iamjenkins
CANVAS_LMS_STATS_COLLECTION: opt_out
CANVAS_LMS_ACCOUNT_NAME: 'School of Butters'
EOF
'''
}
}
stage('Copy Canvas Config') {
steps {
sh '''#!/bin/bash
cp -vr docker-compose/config/*.yml config/
cp -vr config/docker-compose.override.yml.example docker-compose.override.yml
sed -i "/- .:\\/usr\\/src\\/app/d" ./docker-compose.override.yml
sed -i "s/instructure\\/ruby-passenger/local\\/ruby-passenger/g" ./Dockerfile
echo -n "COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml:docker-compose.local.jenkins.yml" > .env
'''
}
}
stage('Copy App Directory') {
steps {
script {
sh """#!/bin/bash
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
CONTAINER="\$(docker create instructure/ruby-passenger:${configuration.ruby()}-jammy)"
docker cp ./ "\$CONTAINER:/usr/src/app/"
docker start \$CONTAINER
docker exec -i --user root \$CONTAINER chown -R docker:docker /usr/src/app/
docker commit \$CONTAINER "local/ruby-passenger:${configuration.ruby()}-jammy"
"""
}
}
}
stage('Build Canvas') {
steps {
sh '''#!/bin/bash
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
source script/common/canvas/build_helpers.sh
build_images
docker_compose_up
build_assets
'''
}
}
stage('Create DB and Migrate') {
steps {
sh '''#!/bin/bash
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
source script/common/canvas/build_helpers.sh
create_db
'''
}
}
stage('Start Canvas Container') {
steps {
sh 'docker compose up -d'
}
}
stage('Test') {
steps {
sh 'docker compose exec -T web bundle exec rspec spec/controllers/oauth2_provider_controller_spec.rb -fd'
}
}
}
post {
always {
script {
buildSummaryReport.saveRunManifest()
}
}
unsuccessful {
script {
def causes = currentBuild.getBuildCauses()[0].shortDescription
if (causes.contains('Started by timer')) {
slackSend(
channel: '#flaky-spec-alerts',
color: 'danger',
message: "${env.JOB_NAME} failed! Build <${env.BUILD_URL}|#${env.BUILD_NUMBER}>\n"
)
}
}
}
}
}