2020-07-08 22:02:55 +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/>.
|
|
|
|
*/
|
|
|
|
|
2021-05-19 00:33:13 +08:00
|
|
|
library 'canvas-builds-library'
|
|
|
|
loadLocalLibrary('local-lib', 'build/new-jenkins/library')
|
2020-07-08 22:02:55 +08:00
|
|
|
|
|
|
|
// if the build never starts or gets into a node block, then we
|
|
|
|
// can never load a file. and a very noisy/confusing error is thrown.
|
|
|
|
def ignoreBuildNeverStartedError(block) {
|
|
|
|
try {
|
|
|
|
block()
|
|
|
|
}
|
|
|
|
catch (org.jenkinsci.plugins.workflow.steps.MissingContextVariableException ex) {
|
|
|
|
if (!ex.message.startsWith('Required context class hudson.FilePath is missing')) {
|
|
|
|
throw ex
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
echo "ignored MissingContextVariableException: \n${ex.message}"
|
|
|
|
}
|
2021-05-19 00:33:13 +08:00
|
|
|
// we can ignore this very noisy error
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-10-10 00:30:33 +08:00
|
|
|
def getMigrationsTag(name) {
|
|
|
|
(env.GERRIT_REFSPEC.contains('master')) || !migrations.cacheLoadFailed() ? migrations.imageMergeTag(name) : migrations.imagePatchsetTag(name)
|
|
|
|
}
|
|
|
|
|
2020-08-04 00:23:52 +08:00
|
|
|
def getPatchsetTag() {
|
|
|
|
(env.GERRIT_REFSPEC.contains('master')) ? "${configuration.buildRegistryPath()}:${env.GERRIT_BRANCH}" : imageTag.patchset()
|
|
|
|
}
|
|
|
|
|
2020-07-08 22:02:55 +08:00
|
|
|
pipeline {
|
|
|
|
agent { label 'canvas-docker' }
|
|
|
|
options {
|
|
|
|
ansiColor('xterm')
|
|
|
|
timestamps()
|
|
|
|
parallelsAlwaysFailFast()
|
|
|
|
}
|
|
|
|
|
|
|
|
environment {
|
|
|
|
BUILD_REGISTRY_FQDN = configuration.buildRegistryFQDN()
|
|
|
|
POSTGRES = configuration.postgres()
|
|
|
|
RUBY = configuration.ruby() // RUBY_VERSION is a reserved keyword for ruby installs
|
|
|
|
// e.g. canvas-lms:01.123456.78-postgres-12-ruby-2.6
|
2020-08-04 00:23:52 +08:00
|
|
|
PATCHSET_TAG = getPatchsetTag()
|
2020-07-08 22:02:55 +08:00
|
|
|
|
2021-01-20 03:15:52 +08:00
|
|
|
CASSANDRA_PREFIX = configuration.buildRegistryPath('cassandra-migrations')
|
|
|
|
DYNAMODB_PREFIX = configuration.buildRegistryPath('dynamodb-migrations')
|
|
|
|
POSTGRES_PREFIX = configuration.buildRegistryPath('postgres-migrations')
|
|
|
|
|
|
|
|
IMAGE_CACHE_MERGE_SCOPE = configuration.gerritBranchSanitized()
|
|
|
|
RSPEC_PROCESSES = 4
|
|
|
|
|
|
|
|
CASSANDRA_IMAGE_TAG = "$CASSANDRA_PREFIX:$IMAGE_CACHE_MERGE_SCOPE-$RSPEC_PROCESSES"
|
|
|
|
DYNAMODB_IMAGE_TAG = "$DYNAMODB_PREFIX:$IMAGE_CACHE_MERGE_SCOPE-$RSPEC_PROCESSES"
|
|
|
|
POSTGRES_IMAGE_TAG = "$POSTGRES_PREFIX:$IMAGE_CACHE_MERGE_SCOPE-$RSPEC_PROCESSES"
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
stages {
|
|
|
|
stage('Setup') {
|
|
|
|
steps {
|
|
|
|
cleanAndSetup()
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Parallel Run Tests') {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
def stages = [:]
|
2020-10-10 00:30:33 +08:00
|
|
|
|
2020-07-08 22:02:55 +08:00
|
|
|
distribution.stashBuildScripts()
|
2021-05-13 06:43:52 +08:00
|
|
|
rspecStage.createDistribution(stages)
|
2020-10-10 00:30:33 +08:00
|
|
|
|
2021-01-20 03:15:52 +08:00
|
|
|
parallel(stages)
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Copy Files') {
|
|
|
|
steps {
|
|
|
|
script {
|
2021-05-13 22:41:58 +08:00
|
|
|
reports.copyParallelLogs('tmp/parallel_runtime_rspec_tests/**/*.log')
|
|
|
|
archiveArtifacts(artifacts: 'parallel_logs/**')
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stage('Create Gerrit') {
|
|
|
|
steps {
|
|
|
|
script {
|
|
|
|
credentials.withGerritCredentials {
|
|
|
|
sh 'build/new-jenkins/push-rspec-parallel-log.sh'
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
post {
|
|
|
|
always {
|
|
|
|
script {
|
|
|
|
ignoreBuildNeverStartedError {
|
2021-03-04 03:35:07 +08:00
|
|
|
node('master') {
|
|
|
|
buildSummaryReport.publishReport('Build Summary Report', currentBuild.getResult() == 'SUCCESS' ? 'SUCCESS' : 'FAILURE')
|
|
|
|
}
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
cleanup {
|
2021-01-12 07:33:50 +08:00
|
|
|
script {
|
|
|
|
ignoreBuildNeverStartedError {
|
|
|
|
libraryScript.execute 'bash/docker-cleanup.sh --allow-failure'
|
|
|
|
}
|
2020-07-08 22:02:55 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|