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/>.
|
|
|
|
*/
|
|
|
|
|
2020-06-17 02:23:25 +08:00
|
|
|
library "canvas-builds-library"
|
|
|
|
|
2019-08-15 02:43:09 +08:00
|
|
|
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'
|
2020-04-27 23:03:34 +08:00
|
|
|
DOCKER_PROCESSES = '6'
|
2020-04-16 02:52:10 +08:00
|
|
|
POSTGRES_PASSWORD = 'sekret'
|
2020-04-27 23:03:34 +08:00
|
|
|
PACT_BROKER = credentials('PACT_BROKER')
|
|
|
|
PACT_BROKER_USERNAME="${env.PACT_BROKER_USR}"
|
|
|
|
PACT_BROKER_PASSWORD="${env.PACT_BROKER_PSW}"
|
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 {
|
2020-06-17 02:23:25 +08:00
|
|
|
cleanAndSetup()
|
2019-12-10 02:37:05 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
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'
|
2020-04-27 23:03:34 +08:00
|
|
|
sh 'build/new-jenkins/pact/docker-compose-pact-setup.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
|
|
|
|
2020-04-27 23:03:34 +08:00
|
|
|
stage('Provider Verification for API and Live Event Consumers') {
|
|
|
|
parallel {
|
|
|
|
stage ('Android') {
|
|
|
|
environment {
|
|
|
|
DATABASE_NAME = 'pact_test1'
|
|
|
|
PACT_API_CONSUMER = 'android'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-api.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/${DATABASE_NAME} ${DATABASE_NAME} --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
|
2020-04-27 23:03:34 +08:00
|
|
|
stage ('Canvas iOS') {
|
|
|
|
environment {
|
|
|
|
DATABASE_NAME = 'pact_test2'
|
|
|
|
PACT_API_CONSUMER = 'canvas-ios'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-api.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/${DATABASE_NAME} ${DATABASE_NAME} --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Generic') {
|
|
|
|
environment {
|
|
|
|
DATABASE_NAME = 'pact_test3'
|
|
|
|
PACT_API_CONSUMER = 'Generic Consumer'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-api.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/${DATABASE_NAME} ${DATABASE_NAME} --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Quiz LTI') {
|
|
|
|
environment {
|
|
|
|
DATABASE_NAME = 'pact_test4'
|
|
|
|
PACT_API_CONSUMER = 'Quiz LTI'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-api.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/${DATABASE_NAME} ${DATABASE_NAME} --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage ('Sistemic') {
|
|
|
|
environment {
|
|
|
|
DATABASE_NAME = 'pact_test5'
|
|
|
|
PACT_API_CONSUMER = 'Sistemic'
|
|
|
|
}
|
|
|
|
steps {
|
|
|
|
timeout(time: 10) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-api.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/${DATABASE_NAME} ${DATABASE_NAME} --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage("Live Events") {
|
|
|
|
steps {
|
|
|
|
timeout(time: 5) {
|
|
|
|
sh 'build/new-jenkins/pact/contracts-verify-live-events.sh'
|
2020-06-18 00:22:23 +08:00
|
|
|
sh 'build/new-jenkins/docker-copy-files.sh /usr/src/app/log/results.xml tmp/spec_results/live_events live_events --allow-error --clean-dir'
|
2020-04-27 23:03:34 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2019-09-12 03:12:40 +08:00
|
|
|
|
|
|
|
post {
|
2020-06-18 00:22:23 +08:00
|
|
|
always {
|
|
|
|
script{
|
|
|
|
junit allowEmptyResults: true, testResults: 'tmp/spec_results/**/*.xml'
|
|
|
|
}
|
|
|
|
}
|
2019-10-04 06:14:15 +08:00
|
|
|
failure {
|
2020-03-10 23:14:44 +08:00
|
|
|
sh 'mkdir -vp spec_results'
|
2020-04-27 23:03:34 +08:00
|
|
|
sh 'docker cp $(docker-compose ps -q 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/'
|
2020-06-17 02:23:25 +08:00
|
|
|
execute 'bash/docker-cleanup.sh --allow-failure'
|
2019-09-12 03:12:40 +08:00
|
|
|
}
|
|
|
|
}
|
2019-08-15 02:43:09 +08:00
|
|
|
}
|