|
| 1 | +/* |
| 2 | + * |
| 3 | + * Licensed to the Apache Software Foundation (ASF) under one or more |
| 4 | + * contributor license agreements. See the NOTICE file distributed with |
| 5 | + * this work for additional information regarding copyright ownership. |
| 6 | + * The ASF licenses this file to You under the Apache License, Version 2.0 |
| 7 | + * (the "License"); you may not use this file except in compliance with |
| 8 | + * the License. You may obtain a copy of the License at |
| 9 | + * |
| 10 | + * http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | + * |
| 12 | + * Unless required by applicable law or agreed to in writing, software |
| 13 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | + * See the License for the specific language governing permissions and |
| 16 | + * limitations under the License. |
| 17 | + * |
| 18 | + */ |
| 19 | + |
| 20 | +def setupGradle() { |
| 21 | + // Delete gradle cache to workaround cache corruption bugs, see KAFKA-3167 |
| 22 | + dir('.gradle') { |
| 23 | + deleteDir() |
| 24 | + } |
| 25 | + sh './gradlew -version' |
| 26 | +} |
| 27 | + |
| 28 | +def doValidation() { |
| 29 | + sh ''' |
| 30 | + ./gradlew -PscalaVersion=$SCALA_VERSION clean compileJava compileScala compileTestJava compileTestScala \ |
| 31 | + spotlessScalaCheck checkstyleMain checkstyleTest spotbugsMain rat \ |
| 32 | + --profile --no-daemon --continue -PxmlSpotBugsReport=true |
| 33 | + ''' |
| 34 | +} |
| 35 | + |
| 36 | +def doTest() { |
| 37 | + sh ''' |
| 38 | + ./gradlew -PscalaVersion=$SCALA_VERSION unitTest integrationTest \ |
| 39 | + --profile --no-daemon --continue -PtestLoggingEvents=started,passed,skipped,failed \ |
| 40 | + -PignoreFailures=true -PmaxParallelForks=2 -PmaxTestRetries=1 -PmaxTestRetryFailures=5 |
| 41 | + ''' |
| 42 | + junit '**/build/test-results/**/TEST-*.xml' |
| 43 | +} |
| 44 | + |
| 45 | +def doStreamsArchetype() { |
| 46 | + echo 'Verify that Kafka Streams archetype compiles' |
| 47 | + |
| 48 | + sh ''' |
| 49 | + ./gradlew streams:install clients:install connect:json:install connect:api:install \ |
| 50 | + || { echo 'Could not install kafka-streams.jar (and dependencies) locally`'; exit 1; } |
| 51 | + ''' |
| 52 | + |
| 53 | + VERSION = sh(script: 'grep "^version=" gradle.properties | cut -d= -f 2', returnStdout: true).trim() |
| 54 | + |
| 55 | + dir('streams/quickstart') { |
| 56 | + sh ''' |
| 57 | + mvn clean install -Dgpg.skip \ |
| 58 | + || { echo 'Could not `mvn install` streams quickstart archetype'; exit 1; } |
| 59 | + ''' |
| 60 | + |
| 61 | + dir('test-streams-archetype') { |
| 62 | + // Note the double quotes for variable interpolation |
| 63 | + sh """ |
| 64 | + echo "Y" | mvn archetype:generate \ |
| 65 | + -DarchetypeCatalog=local \ |
| 66 | + -DarchetypeGroupId=org.apache.kafka \ |
| 67 | + -DarchetypeArtifactId=streams-quickstart-java \ |
| 68 | + -DarchetypeVersion=${VERSION} \ |
| 69 | + -DgroupId=streams.examples \ |
| 70 | + -DartifactId=streams.examples \ |
| 71 | + -Dversion=0.1 \ |
| 72 | + -Dpackage=myapps \ |
| 73 | + || { echo 'Could not create new project using streams quickstart archetype'; exit 1; } |
| 74 | + """ |
| 75 | + |
| 76 | + dir('streams.examples') { |
| 77 | + sh ''' |
| 78 | + mvn compile \ |
| 79 | + || { echo 'Could not compile streams quickstart archetype project'; exit 1; } |
| 80 | + ''' |
| 81 | + } |
| 82 | + } |
| 83 | + } |
| 84 | +} |
| 85 | + |
| 86 | +def tryStreamsArchetype() { |
| 87 | + try { |
| 88 | + doStreamsArchetype() |
| 89 | + } catch(err) { |
| 90 | + echo 'Failed to build Kafka Streams archetype, marking this build UNSTABLE' |
| 91 | + currentBuild.result = 'UNSTABLE' |
| 92 | + } |
| 93 | +} |
| 94 | + |
| 95 | + |
| 96 | +pipeline { |
| 97 | + agent none |
| 98 | + stages { |
| 99 | + stage('Build') { |
| 100 | + parallel { |
| 101 | + stage('JDK 8 and Scala 2.11') { |
| 102 | + agent { label 'ubuntu' } |
| 103 | + tools { |
| 104 | + jdk 'JDK 1.8 (latest)' |
| 105 | + maven 'Maven 3.6.3' |
| 106 | + } |
| 107 | + options { |
| 108 | + timeout(time: 8, unit: 'HOURS') |
| 109 | + timestamps() |
| 110 | + } |
| 111 | + environment { |
| 112 | + SCALA_VERSION=2.11 |
| 113 | + } |
| 114 | + steps { |
| 115 | + setupGradle() |
| 116 | + doValidation() |
| 117 | + doTest() |
| 118 | + tryStreamsArchetype() |
| 119 | + } |
| 120 | + } |
| 121 | + |
| 122 | + stage('JDK 11 and Scala 2.12') { |
| 123 | + agent { label 'ubuntu' } |
| 124 | + tools { |
| 125 | + jdk 'JDK 11 (latest)' |
| 126 | + } |
| 127 | + options { |
| 128 | + timeout(time: 8, unit: 'HOURS') |
| 129 | + timestamps() |
| 130 | + } |
| 131 | + environment { |
| 132 | + SCALA_VERSION=2.12 |
| 133 | + } |
| 134 | + steps { |
| 135 | + setupGradle() |
| 136 | + doValidation() |
| 137 | + doTest() |
| 138 | + echo 'Skipping Kafka Streams archetype test for Java 11' |
| 139 | + } |
| 140 | + } |
| 141 | + |
| 142 | + stage('JDK 11 and Scala 2.13') { |
| 143 | + agent { label 'ubuntu' } |
| 144 | + tools { |
| 145 | + jdk 'JDK 11 (latest)' |
| 146 | + } |
| 147 | + options { |
| 148 | + timeout(time: 8, unit: 'HOURS') |
| 149 | + timestamps() |
| 150 | + } |
| 151 | + environment { |
| 152 | + SCALA_VERSION=2.13 |
| 153 | + } |
| 154 | + steps { |
| 155 | + setupGradle() |
| 156 | + doValidation() |
| 157 | + doTest() |
| 158 | + echo 'Skipping Kafka Streams archetype test for Java 11' |
| 159 | + } |
| 160 | + } |
| 161 | + } |
| 162 | + } |
| 163 | + } |
| 164 | +} |
0 commit comments