From edaa0635913e5a3e7124993f305d52bdb3ea9490 Mon Sep 17 00:00:00 2001 From: Simon Bernard Date: Tue, 12 Dec 2023 15:25:50 +0100 Subject: [PATCH] Add Manual test job to jenkins --- .jenkins/test.jenkins | 77 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 .jenkins/test.jenkins diff --git a/.jenkins/test.jenkins b/.jenkins/test.jenkins new file mode 100644 index 0000000000..5e95d26ecf --- /dev/null +++ b/.jenkins/test.jenkins @@ -0,0 +1,77 @@ +/************************************************************************************ + + Manual job used to test to build a branch on jenkins + Take 1 parameters (BRANCH). + + Checks out current ${BRANCH}'s HEAD + +*************************************************************************************/ +pipeline { + agent any + parameters { + string( + name: 'BRANCH', + defaultValue: 'master', + description: 'The branch to build. Examples: master, 1.x') + booleanParam( + name: 'TEST_WITH_TOOLCHAIN', + defaultValue: false, + description: 'To execute tests using toolchain') + string( + name: 'JDK_TOOLCHAIN_VERSION', + defaultValue: '', + description: 'The jdk version used to execute tests when `TEST_WITH_TOOLCHAIN` is used. (e.g. 1.7 1.8 11 17 21 ...). By default, this is an empty string which means use minimal supported java version') + } + tools { + maven 'apache-maven-latest' + jdk 'temurin-jdk11-latest' + } + options { + timeout (time: 30, unit: 'MINUTES') + buildDiscarder(logRotator(numToKeepStr: '3')) + disableConcurrentBuilds() + skipDefaultCheckout() + durabilityHint('PERFORMANCE_OPTIMIZED') + } + stages { + stage('Build') { + steps { + // Checkout code + git url: 'git@github.com:eclipse-leshan/leshan.git', + credentialsId: 'github-bot-ssh', + branch: '${BRANCH}' + + // Build + sh ''' mvn -B com.github.ekryd.sortpom:sortpom-maven-plugin:verify -PallPom ''' + // This ssh agent is needed to cache yarn/node to download.eclipse.org when using -PeclipseJenkins + // see : https://github.com/eclipse-leshan/leshan/pull/1484 + sshagent ( ['projects-storage.eclipse.org-bot-ssh']) { + sh ''' mvn -B clean install javadoc:javadoc -PeclipseJenkins -DskipTests''' + } + + + // test with + // - given toolchain version + // - OR minimal version supported + // - OR jvm used to build. + sh ''' + if [[ $TEST_WITH_TOOLCHAIN == true ]]; then + if [[ -n $JDK_TOOLCHAIN_VERSION ]]; then + mvn -B test -PuseToolchain -Dskip.yarn -Dtoolchain.version="${JDK_TOOLCHAIN_VERSION}" + else + mvn -B test -PuseToolchain -Dskip.yarn + fi + else + mvn -B test -Dskip.yarn + fi + ''' + + // Copy artifacts + sh ''' cp leshan-server-demo/target/leshan-server-demo-*-jar-with-dependencies.jar leshan-server-demo.jar + cp leshan-bsserver-demo/target/leshan-bsserver-demo-*-jar-with-dependencies.jar leshan-bsserver-demo.jar + cp leshan-client-demo/target/leshan-client-demo-*-jar-with-dependencies.jar leshan-client-demo.jar + ''' + } + } + } +}