|
| 1 | +#!groovy |
| 2 | + |
| 3 | +/* |
| 4 | + * Licensed to the Apache Software Foundation (ASF) under one |
| 5 | + * or more contributor license agreements. See the NOTICE file |
| 6 | + * distributed with this work for additional information |
| 7 | + * regarding copyright ownership. The ASF licenses this file |
| 8 | + * to you under the Apache License, Version 2.0 (the |
| 9 | + * "License"); you may not use this file except in compliance |
| 10 | + * with the License. You may obtain a copy of the License at |
| 11 | + * |
| 12 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 13 | + * |
| 14 | + * Unless required by applicable law or agreed to in writing, |
| 15 | + * software distributed under the License is distributed on an |
| 16 | + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 17 | + * KIND, either express or implied. See the License for the |
| 18 | + * specific language governing permissions and limitations |
| 19 | + * under the License. |
| 20 | + */ |
| 21 | + |
| 22 | +pipeline { |
| 23 | + agent { |
| 24 | + label 'cassandra-small' |
| 25 | + } |
| 26 | + |
| 27 | + triggers { |
| 28 | + // schedules only run against release branches (i.e. 3.x, 4.x, 4.5.x, etc.) |
| 29 | + cron(branchPatternCron().matcher(env.BRANCH_NAME).matches() ? '@weekly' : '') |
| 30 | + } |
| 31 | + |
| 32 | + stages { |
| 33 | + stage('Matrix') { |
| 34 | + matrix { |
| 35 | + axes { |
| 36 | + axis { |
| 37 | + name 'TEST_JAVA_VERSION' |
| 38 | + |
| 39 | + } |
| 40 | + axis { |
| 41 | + name 'SERVER_VERSION' |
| 42 | + values '3.11.17', |
| 43 | + '4.0.13', |
| 44 | + '5.0-beta1' |
| 45 | + } |
| 46 | + } |
| 47 | + stages { |
| 48 | + stage('Tests') { |
| 49 | + agent { |
| 50 | + label 'cassandra-medium' |
| 51 | + } |
| 52 | + steps { |
| 53 | + script { |
| 54 | + executeTests() |
| 55 | + junit testResults: '**/target/surefire-reports/TEST-*.xml', allowEmptyResults: true |
| 56 | + junit testResults: '**/target/failsafe-reports/TEST-*.xml', allowEmptyResults: true |
| 57 | + } |
| 58 | + } |
| 59 | + } |
| 60 | + } |
| 61 | + } |
| 62 | + } |
| 63 | + } |
| 64 | +} |
| 65 | + |
| 66 | +def executeTests() { |
| 67 | + def testJavaMajorVersion = (TEST_JAVA_VERSION =~ /@(?:1\.)?(\d+)/)[0][1] |
| 68 | + sh """ |
| 69 | + container_id=\$(docker run -td -e TEST_JAVA_VERSION=${TEST_JAVA_VERSION} -e SERVER_VERSION=${SERVER_VERSION} -e TEST_JAVA_MAJOR_VERSION=${testJavaMajorVersion} -v \$(pwd):/home/docker/cassandra-java-driver apache.jfrog.io/cassan-docker/apache/cassandra-java-driver-testing-ubuntu2204 'sleep 2h') |
| 70 | + docker exec --user root \$container_id bash -c \"sudo bash /home/docker/cassandra-java-driver/ci/create-user.sh docker \$(id -u) \$(id -g) /home/docker/cassandra-java-driver\" |
| 71 | + docker exec --user docker \$container_id './cassandra-java-driver/ci/run-tests.sh' |
| 72 | + ( nohup docker stop \$container_id >/dev/null 2>/dev/null & ) |
| 73 | + """ |
| 74 | +} |
| 75 | + |
| 76 | +// branch pattern for cron |
| 77 | +// should match 3.x, 4.x, 4.5.x, etc |
| 78 | +def branchPatternCron() { |
| 79 | + ~'((\\d+(\\.[\\dx]+)+))' |
| 80 | +} |
0 commit comments