diff --git a/Jenkinsfile b/Jenkinsfile index c7df4c5b18c..826f7818c59 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -50,10 +50,7 @@ def doStreamsArchetype() { || { echo 'Could not install kafka-streams.jar (and dependencies) locally`'; exit 1; } ''' - sh ''' - version=`grep "^version=" gradle.properties | cut -d= -f 2` \ - || { echo 'Could not get version from `gradle.properties`'; exit 1; } - ''' + VERSION = sh(script: 'grep "^version=" gradle.properties | cut -d= -f 2', returnStdout: true).trim() dir('streams/quickstart') { sh ''' @@ -61,29 +58,27 @@ def doStreamsArchetype() { || { echo 'Could not `mvn install` streams quickstart archetype'; exit 1; } ''' - sh ''' - mkdir test-streams-archetype && cd test-streams-archetype \ - || { echo 'Could not create test directory for stream quickstart archetype'; exit 1; } - ''' - - sh ''' - echo "Y" | mvn archetype:generate \ - -DarchetypeCatalog=local \ - -DarchetypeGroupId=org.apache.kafka \ - -DarchetypeArtifactId=streams-quickstart-java \ - -DarchetypeVersion=$version \ - -DgroupId=streams.examples \ - -DartifactId=streams.examples \ - -Dversion=0.1 \ - -Dpackage=myapps \ - || { echo 'Could not create new project using streams quickstart archetype'; exit 1; } - ''' + dir('test-streams-archetype') { + // Note the double quotes for variable interpolation + sh """ + echo "Y" | mvn archetype:generate \ + -DarchetypeCatalog=local \ + -DarchetypeGroupId=org.apache.kafka \ + -DarchetypeArtifactId=streams-quickstart-java \ + -DarchetypeVersion=${VERSION} \ + -DgroupId=streams.examples \ + -DartifactId=streams.examples \ + -Dversion=0.1 \ + -Dpackage=myapps \ + || { echo 'Could not create new project using streams quickstart archetype'; exit 1; } + """ - dir('streams.examples') { - sh ''' - mvn compile \ - || { echo 'Could not compile streams quickstart archetype project'; exit 1; } - ''' + dir('streams.examples') { + sh ''' + mvn compile \ + || { echo 'Could not compile streams quickstart archetype project'; exit 1; } + ''' + } } } }