2020-08-22 03:42:49 +08:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2020 - 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/>.
|
|
|
|
*/
|
|
|
|
import org.jenkinsci.plugins.workflow.support.steps.build.DownstreamFailureCause
|
|
|
|
import org.jenkinsci.plugins.workflow.steps.FlowInterruptedException
|
|
|
|
|
2020-11-02 23:39:02 +08:00
|
|
|
library "canvas-builds-library@${env.CANVAS_BUILDS_REFSPEC}"
|
2020-08-22 03:42:49 +08:00
|
|
|
|
|
|
|
pipeline {
|
|
|
|
agent none
|
|
|
|
options {
|
|
|
|
ansiColor('xterm')
|
2021-01-07 01:11:17 +08:00
|
|
|
timeout(time: 22)
|
2020-08-22 03:42:49 +08:00
|
|
|
timestamps()
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
JENKINS = 'true'
|
2021-04-01 04:50:51 +08:00
|
|
|
DOCKER='y'
|
2020-08-22 03:42:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Environment') {
|
|
|
|
steps {
|
|
|
|
script {
|
2021-04-14 00:48:18 +08:00
|
|
|
protectedNode('canvas-docker') {
|
2020-08-22 03:42:49 +08:00
|
|
|
stage('Setup') {
|
2020-11-18 02:50:39 +08:00
|
|
|
// always pull from gerrit refspec to test the changed docker dev code
|
2020-11-03 23:22:18 +08:00
|
|
|
checkoutRepo("canvas-lms", env.GERRIT_REFSPEC, 1)
|
2021-03-11 04:38:09 +08:00
|
|
|
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
|
|
|
|
'''
|
2020-08-22 03:42:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Copy Canvas Config') {
|
|
|
|
sh 'cp -vr docker-compose/config/*.yml config/'
|
|
|
|
sh 'cp -vr config/docker-compose.override.yml.example docker-compose.override.yml'
|
2021-03-11 04:38:09 +08:00
|
|
|
sh 'echo -n "COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml:docker-compose.local.jenkins.yml" > .env'
|
2020-08-22 03:42:49 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stage('Build Canvas') {
|
|
|
|
sh '''#!/bin/bash
|
|
|
|
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
2021-03-17 04:02:59 +08:00
|
|
|
source script/common/canvas/build_helpers.sh
|
2020-08-22 03:42:49 +08:00
|
|
|
|
|
|
|
build_images
|
|
|
|
check_gemfile
|
2021-04-01 04:50:51 +08:00
|
|
|
docker_compose_up
|
2020-11-06 05:12:42 +08:00
|
|
|
build_assets
|
2020-08-22 03:42:49 +08:00
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Create DB and Migrate') {
|
|
|
|
sh '''#!/bin/bash
|
|
|
|
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
2021-03-17 04:02:59 +08:00
|
|
|
source script/common/canvas/build_helpers.sh
|
2020-08-22 03:42:49 +08:00
|
|
|
|
|
|
|
create_db
|
|
|
|
'''
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Start Canvas Container') {
|
|
|
|
sh 'docker-compose up -d'
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Test') {
|
|
|
|
sh 'docker-compose exec -T web bundle exec rspec spec/controllers/oauth2_provider_controller_spec.rb -fd'
|
|
|
|
}
|
|
|
|
}//protectedNode
|
|
|
|
}//script
|
|
|
|
}//steps
|
|
|
|
}//environment
|
|
|
|
}//stages
|
2020-10-03 03:27:25 +08:00
|
|
|
|
|
|
|
post {
|
|
|
|
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"
|
|
|
|
)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2020-08-22 03:42:49 +08:00
|
|
|
}//pipeline
|