From f52a6e3d996f27e8fd3f7b46560530855a882a06 Mon Sep 17 00:00:00 2001 From: Robert Vokac Date: Sat, 2 Sep 2023 16:05:06 +0200 Subject: [PATCH] Added Jenkins support --- Jenkinsfile | 107 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) create mode 100644 Jenkinsfile diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 0000000..410f6e4 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,107 @@ +pipeline +/* +Power Framework + +Requirements: + +Maven is Installed + +Java 19 is installed + +*/ +{ + agent any + environment { + AAA = 'aaa' + } + stages + { + stage('Build') + { + steps { + + echo "*** Building ${env.JOB_NAME} ***" + sh ''' + #!/bin/bash + echo JOB_NAME=$JOB_NAME + + case $BRANCH_NAME in + + master | deploy_prod) + mvn clean install + ;; + + develop | jenkins | deploy_test) + echo Branch $BRANCH_NAME is supported. Continuing. + version=`mvn help:evaluate -Dexpression=project.version -q -DforceStdout` + echo version=$version + case "$version" in + *"SNAPSHOT"*) echo echo version is OK ;; + * ) echo echo "You cannot build releases on Jenkins, only snapshots!"&&exit 1 ;; + esac + mvn clean deploy + ;; + + *) + echo Branch $BRANCH_NAME is not supported. A failure happened. Exiting. + exit 1 + ;; + esac + + echo "Build of $JOB_NAME was successful" + ''' + } + } + + stage('Deploy') + { + steps { + echo "*** Deploying ${env.JOB_NAME} ***" + + sh ''' + #!/bin/bash + + echo "Nothing to do" + exit + + case $BRANCH_NAME in + + master | deploy_prod) + echo Branch $BRANCH_NAME is supported. Continuing. + TOMCAT_HOME=$TOMCAT10_HOME + systemdService=tomcat10 + ;; + + develop | jenkins | deploy_test) + echo Branch $BRANCH_NAME is supported. Continuing. + TOMCAT_HOME=$TOMCAT10_TEST_HOME + systemdService=tomcat10test + ;; + + *) + echo Branch $BRANCH_NAME is not supported. A failure happened. Exiting. + exit 1 + ;; + esac + + ''' + + } + } + } + post { + always { + script { + env.color = "${currentBuild.currentResult == 'SUCCESS' ? 'green' : 'red'}" + } + + echo 'Sending e-mail.' + sh "printenv | sort" + emailext body: "${currentBuild.currentResult} - ${env.JOB_NAME} (#${env.BUILD_NUMBER})
", + recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']], + subject: "Jenkins Build - ${currentBuild.currentResult} - $JOB_NAME (#$BUILD_NUMBER)" + + } + } +} +