-
Notifications
You must be signed in to change notification settings - Fork 89
/
Jenkinsfile
100 lines (86 loc) · 2.48 KB
/
Jenkinsfile
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
def initializeEnvironment() {
env.DRIVER_DISPLAY_NAME = 'Cassandra Ruby Driver'
env.DRIVER_METRIC_TYPE = 'oss'
env.GIT_SHA = "${env.GIT_COMMIT.take(7)}"
env.GITHUB_PROJECT_URL = "https://${GIT_URL.replaceFirst(/(git@|http:\/\/|https:\/\/)/, '').replace(':', '/').replace('.git', '')}"
env.GITHUB_BRANCH_URL = "${GITHUB_PROJECT_URL}/tree/${env.BRANCH_NAME}"
env.GITHUB_COMMIT_URL = "${GITHUB_PROJECT_URL}/commit/${env.GIT_COMMIT}"
sh label: 'Download Apache CassandraⓇ or DataStax Enterprise', script: '''#!/bin/bash -lex
. ${CCM_ENVIRONMENT_SHELL} ${CASSANDRA_VERSION}
'''
}
def installDependencies() {
sh label: 'Set Ruby env and update gems', script: '''#!/bin/bash -le
rbenv global ${RUBY_VERSION}
ruby_bin_version=`ruby -v`
echo "Ruby binary version: ${ruby_bin_version}"
if [[ $ruby_bin_version == jruby* ]]; then
# Add '-java' to version as that is included in version name when using jruby
echo "JRuby detected, updating Gemfile.lock"
sed -i -r 's/cassandra-driver \\((.*)\\)/cassandra-driver (\\1-java)/' Gemfile.lock
fi
bundle update --bundler
bundle --version
bundle install --without development docs
'''
}
def executeTests() {
sh label: 'Execute all tests', script: '''#!/bin/bash -le
# Load CCM environment variables
set -o allexport
. ${HOME}/environment.txt
set +o allexport
bundle exec rake test
'''
}
pipeline {
agent none
// Global pipeline timeout
options {
timeout(time: 10, unit: 'HOURS')
buildDiscarder(logRotator(artifactNumToKeepStr: '10', // Keep only the last 10 artifacts
numToKeepStr: '50')) // Keep only the last 50 build records
}
environment {
CCM_ENVIRONMENT_SHELL = '/usr/local/bin/ccm_environment.sh'
}
stages {
stage('Per-Commit') {
environment {
OS_VERSION = 'ubuntu/bionic64/ruby-driver'
}
matrix {
axes {
axis {
name 'CASSANDRA_VERSION'
values '2.1', '3.11', '4.0'
}
axis {
name 'RUBY_VERSION'
values '2.3.6', '2.4.3', '2.7.0', 'jruby-9.1.15.0'
}
}
agent {
label "${OS_VERSION}"
}
stages {
stage('Initialize-Environment') {
steps {
initializeEnvironment()
}
}
stage('Install-Dependencies') {
steps {
installDependencies()
}
}
stage('Execute-Tests') {
steps {
executeTests()
}
}
}
}
}
}
}