107 lines
3.2 KiB
Groovy
107 lines
3.2 KiB
Groovy
#!/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
|
|
|
|
library "canvas-builds-library@${env.CANVAS_BUILDS_REFSPEC}"
|
|
|
|
def cleanupFn() {
|
|
libraryScript.execute 'bash/docker-cleanup.sh --allow-failure'
|
|
}
|
|
|
|
pipeline {
|
|
agent none
|
|
options {
|
|
ansiColor('xterm')
|
|
timeout(time: 22)
|
|
timestamps()
|
|
}
|
|
|
|
environment {
|
|
COMPOSE_FILE = 'docker-compose.yml:docker-compose.override.yml'
|
|
JENKINS = 'true'
|
|
}
|
|
|
|
stages {
|
|
stage('Environment') {
|
|
steps {
|
|
script {
|
|
protectedNode('canvas-docker', { cleanupFn() }) {
|
|
stage('Setup') {
|
|
cleanAndSetup()
|
|
// always pull from gerrit refspec to test the changed docker dev code
|
|
checkoutRepo("canvas-lms", env.GERRIT_REFSPEC, 1)
|
|
}
|
|
|
|
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'
|
|
sh 'echo -n "COMPOSE_FILE=docker-compose.yml:docker-compose.override.yml" > .env'
|
|
}
|
|
|
|
stage('Build Canvas') {
|
|
sh '''#!/bin/bash
|
|
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
|
source build/common_docker_build_steps.sh
|
|
|
|
build_images
|
|
check_gemfile
|
|
build_assets
|
|
'''
|
|
}
|
|
|
|
stage('Create DB and Migrate') {
|
|
sh '''#!/bin/bash
|
|
set -o errexit -o errtrace -o nounset -o pipefail -o xtrace
|
|
source build/common_docker_build_steps.sh
|
|
|
|
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
|
|
|
|
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"
|
|
)
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}//pipeline
|