forked from instructure/canvas-lms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Jenkinsfile.parallel_logs
134 lines (117 loc) · 3.79 KB
/
Jenkinsfile.parallel_logs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
#!/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/>.
*/
library 'canvas-builds-library'
loadLocalLibrary('local-lib', 'build/new-jenkins/library')
// 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}"
}
// we can ignore this very noisy error
}
}
def getMigrationsTag(name) {
(env.GERRIT_REFSPEC.contains('master')) || !migrations.cacheLoadFailed() ? migrations.imageMergeTag(name) : migrations.imagePatchsetTag(name)
}
def getPatchsetTag() {
(env.GERRIT_REFSPEC.contains('master')) ? "${configuration.buildRegistryPath()}:${env.GERRIT_BRANCH}" : imageTag.patchset()
}
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
PATCHSET_TAG = getPatchsetTag()
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"
}
stages {
stage('Setup') {
steps {
cleanAndSetup()
}
}
stage('Parallel Run Tests') {
steps {
script {
def stages = [:]
distribution.stashBuildScripts()
rspecStage.createDistribution(stages)
parallel(stages)
}
}
}
stage('Copy Files') {
steps {
script {
reports.copyParallelLogs('tmp/parallel_runtime_rspec_tests/**/*.log')
archiveArtifacts(artifacts: 'parallel_logs/**')
}
}
}
stage('Create Gerrit') {
steps {
script {
credentials.withGerritCredentials {
sh 'build/new-jenkins/push-rspec-parallel-log.sh'
}
}
}
}
}
post {
always {
script {
ignoreBuildNeverStartedError {
node('master') {
buildSummaryReport.publishReport('Build Summary Report', currentBuild.getResult() == 'SUCCESS' ? 'SUCCESS' : 'FAILURE')
}
}
}
}
cleanup {
script {
ignoreBuildNeverStartedError {
libraryScript.execute 'bash/docker-cleanup.sh --allow-failure'
}
}
}
}
}