2019-08-15 02:43:09 +08:00
|
|
|
#!/usr/bin/env groovy
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright (C) 2019 - 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/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
pipeline {
|
2019-09-12 03:12:40 +08:00
|
|
|
agent { label 'canvas-docker' }
|
2020-05-09 02:23:07 +08:00
|
|
|
options {
|
|
|
|
ansiColor('xterm')
|
|
|
|
timestamps()
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
|
|
|
|
environment {
|
|
|
|
COMPOSE_FILE = 'docker-compose.new-jenkins.yml'
|
2019-09-12 03:12:40 +08:00
|
|
|
PACT_BROKER = credentials('PACT_BROKER')
|
2020-04-16 02:52:10 +08:00
|
|
|
POSTGRES_PASSWORD = 'sekret'
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
|
2019-08-15 02:43:09 +08:00
|
|
|
stages {
|
2019-12-10 02:37:05 +08:00
|
|
|
stage ('Pre-Cleanup') {
|
|
|
|
steps {
|
|
|
|
timeout(time: 2) {
|
|
|
|
sh 'build/new-jenkins/docker-cleanup.sh'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-12 03:12:40 +08:00
|
|
|
stage('Start Docker Images') {
|
2019-08-15 02:43:09 +08:00
|
|
|
steps {
|
2019-09-12 03:12:40 +08:00
|
|
|
timeout(time: 10) {
|
2020-01-10 04:03:33 +08:00
|
|
|
sh 'build/new-jenkins/docker-compose-pull.sh'
|
|
|
|
sh 'build/new-jenkins/docker-compose-build-up.sh'
|
2020-04-26 00:56:59 +08:00
|
|
|
sh 'build/new-jenkins/docker-compose-setup-databases.sh'
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
}
|
2019-09-21 03:40:47 +08:00
|
|
|
|
2019-10-25 00:09:24 +08:00
|
|
|
stage ('API Contract Tests') {
|
2019-09-21 03:40:47 +08:00
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh """
|
2020-05-02 05:04:18 +08:00
|
|
|
docker-compose --project-name canvas-lms0 exec -T canvas env \
|
2019-09-21 03:40:47 +08:00
|
|
|
PACT_BROKER_HOST=inst-pact-broker.inseng.net \
|
|
|
|
PACT_BROKER_USERNAME="${env.PACT_BROKER_USR}" \
|
|
|
|
PACT_BROKER_PASSWORD="${env.PACT_BROKER_PSW}" \
|
|
|
|
JENKINS_URL="this silliness is necessary." \
|
|
|
|
DATABASE_CLEANER_ALLOW_REMOTE_DATABASE_URL=true \
|
|
|
|
bin/contracts-verify-api
|
|
|
|
"""
|
2019-09-12 03:12:40 +08:00
|
|
|
}
|
2019-09-21 03:40:47 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
|
2019-09-21 03:40:47 +08:00
|
|
|
stage("Live Events Contract Tests") {
|
|
|
|
steps {
|
|
|
|
sh """
|
2020-05-02 05:04:18 +08:00
|
|
|
docker-compose --project-name canvas-lms0 exec -T canvas env \
|
2019-09-21 03:40:47 +08:00
|
|
|
PACT_BROKER_HOST=inst-pact-broker.inseng.net \
|
|
|
|
PACT_BROKER_USERNAME="${env.PACT_BROKER_USR}" \
|
|
|
|
PACT_BROKER_PASSWORD="${env.PACT_BROKER_PSW}" \
|
|
|
|
bin/contracts-verify-live-events
|
|
|
|
"""
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
|
|
|
|
post {
|
2019-10-04 06:14:15 +08:00
|
|
|
failure {
|
2020-03-10 23:14:44 +08:00
|
|
|
sh 'mkdir -vp spec_results'
|
2020-05-02 05:04:18 +08:00
|
|
|
sh 'docker cp $(docker ps -q --filter "name=canvas_"):/usr/src/app/log/spec_failures/. ./spec_results/'
|
2019-10-04 06:14:15 +08:00
|
|
|
script {
|
|
|
|
dir('spec_results') {
|
|
|
|
htmlFiles = findFiles glob: '**/index.html'
|
|
|
|
}
|
|
|
|
|
|
|
|
publishHTML(target: [
|
|
|
|
allowMissing: false,
|
|
|
|
alwaysLinkToLastBuild: false,
|
|
|
|
keepAll: true,
|
|
|
|
reportDir: "spec_results",
|
|
|
|
reportFiles: htmlFiles.join(','),
|
|
|
|
reportName: 'Test Results'
|
|
|
|
])
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
cleanup {
|
2020-03-10 23:14:44 +08:00
|
|
|
sh 'rm -vrf spec_results/'
|
2019-12-11 03:58:45 +08:00
|
|
|
sh 'build/new-jenkins/docker-cleanup.sh --allow-failure'
|
2019-09-12 03:12:40 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|