Added Jenkins support
nanoboot/nanodata/pipeline/head This commit looks good
Details
nanoboot/nanodata/pipeline/head This commit looks good
Details
This commit is contained in:
parent
d6e50d50f2
commit
b2ab35f1c1
|
@ -0,0 +1,147 @@
|
|||
pipeline
|
||||
/*
|
||||
|
||||
Nanodata
|
||||
|
||||
Requirements:
|
||||
|
||||
Following variables are set in Jenkins:
|
||||
* TOMCAT10_HOME
|
||||
* TOMCAT10_TEST_HOME
|
||||
|
||||
Maven is Installed
|
||||
|
||||
Java 21 is installed - variable JAVA_21_HOME is set
|
||||
|
||||
Following Systemd services are installed:
|
||||
tomcat10
|
||||
tomcat10test
|
||||
|
||||
*/
|
||||
{
|
||||
agent any
|
||||
environment {
|
||||
AAA = 'aaa'
|
||||
}
|
||||
stages
|
||||
{
|
||||
stage('Build')
|
||||
{
|
||||
steps {
|
||||
|
||||
echo "*** Building ${env.JOB_NAME} ***"
|
||||
sh '''
|
||||
#!/bin/bash
|
||||
echo JOB_NAME=$JOB_NAME
|
||||
|
||||
if [ -z "$JAVA_21_HOME" ]
|
||||
then
|
||||
echo "KO : Variable JAVA_21_HOME is empty. You fix this issue by adding this variable to configuration of Jenkins."
|
||||
exit 1
|
||||
else
|
||||
echo "OK : Variable JAVA_21_HOME is NOT empty"
|
||||
fi
|
||||
export JAVA_HOME=$JAVA_21_HOME
|
||||
|
||||
mvn clean install -X
|
||||
|
||||
echo "Build of $JOB_NAME was successful"
|
||||
'''
|
||||
}
|
||||
}
|
||||
|
||||
stage('Deploy')
|
||||
{
|
||||
steps {
|
||||
echo "*** Deploying ${env.JOB_NAME} ***"
|
||||
|
||||
sh '''
|
||||
#!/bin/bash
|
||||
|
||||
#echo "Nothing to do"
|
||||
#exit
|
||||
|
||||
if [ -z "$TOMCAT10_HOME" ]
|
||||
then
|
||||
echo "KO : Variable TOMCAT10_HOME is empty. You fix this issue by adding this variable to configuration of Jenkins."
|
||||
exit 1
|
||||
else
|
||||
echo "OK : Variable TOMCAT10_HOME is NOT empty"
|
||||
fi
|
||||
|
||||
if [ -z "$TOMCAT10_TEST_HOME" ]
|
||||
then
|
||||
echo "KO : Variable TOMCAT10_TEST_HOME is empty. You fix this issue by adding this variable to configuration of Jenkins."
|
||||
exit 1
|
||||
else
|
||||
echo "OK : Variable TOMCAT10_TEST_HOME is NOT empty"
|
||||
fi
|
||||
|
||||
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
|
||||
|
||||
mv nanodata-web/target/nanodata-web-*.war nanodata.war
|
||||
|
||||
|
||||
currentDir=`pwd`&&cd $TOMCAT_HOME/bin
|
||||
#./catalina.sh stop
|
||||
sudo systemctl stop $systemdService
|
||||
sleep 5
|
||||
|
||||
if [ -f "$TOMCAT_HOME/webapps/nanodata.war" ]; then
|
||||
rm $TOMCAT_HOME/webapps/nanodata.war
|
||||
fi
|
||||
|
||||
if [ -f "$TOMCAT_HOME/webapps/nanodata" ]; then
|
||||
rm -r $TOMCAT_HOME/webapps/nanodata
|
||||
fi
|
||||
mv $currentDir/nanodata.war $TOMCAT_HOME/webapps
|
||||
|
||||
#(
|
||||
# set -e
|
||||
# export BUILD_ID=dontKillMe
|
||||
# export JENKINS_NODE_COOKIE=dontKillMe
|
||||
# ./catalina.sh start &
|
||||
#) &
|
||||
sudo systemctl start $systemdService
|
||||
|
||||
cd $currentDir
|
||||
|
||||
'''
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
post {
|
||||
always {
|
||||
script {
|
||||
env.color = "${currentBuild.currentResult == 'SUCCESS' ? 'green' : 'red'}"
|
||||
}
|
||||
|
||||
echo 'Sending e-mail.'
|
||||
sh "printenv | sort"
|
||||
emailext body: "<b style=\"color:$COLOR\">${currentBuild.currentResult}</b> - ${env.JOB_NAME} (#${env.BUILD_NUMBER})<br> <ul style=\"margin-top:2px;padding-top:2px;padding-left:30px;\"><li>More info at: <a href=\"${env.BUILD_URL}\">${env.BUILD_URL}</a></li></ul>",
|
||||
recipientProviders: [[$class: 'DevelopersRecipientProvider'], [$class: 'RequesterRecipientProvider']],
|
||||
subject: "Jenkins Build - ${currentBuild.currentResult} - $JOB_NAME (#$BUILD_NUMBER)"
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -52,7 +52,7 @@
|
|||
<plugin>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<artifactId>build-helper-maven-plugin</artifactId>
|
||||
<version>3.2.0</version>
|
||||
<version>${build-helper-maven-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>add-resource</id>
|
||||
|
|
12
pom.xml
12
pom.xml
|
@ -26,7 +26,7 @@
|
|||
<parent>
|
||||
<groupId>org.nanoboot.essential</groupId>
|
||||
<artifactId>nanoboot-parent</artifactId>
|
||||
<version>0.1.0</version>
|
||||
<version>0.1.1-SNAPSHOT</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.nanoboot.nanodata</groupId>
|
||||
|
@ -47,12 +47,9 @@
|
|||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
<nanodata.version>0.0.1-SNAPSHOT</nanodata.version>
|
||||
<power.version>2.0.0</power.version>
|
||||
<log4j.version>2.17.0</log4j.version>
|
||||
<springframework.version>6.0.7</springframework.version>
|
||||
<power.version>2.0.1-SNAPSHOT</power.version>
|
||||
<checkstyle.skip>true</checkstyle.skip><!-- TODO: make false-->
|
||||
<maven-war-plugin.version>3.3.2</maven-war-plugin.version>
|
||||
<db-migration-core.version>0.1.0</db-migration-core.version>
|
||||
<db-migration-core.version>0.1.1-SNAPSHOT</db-migration-core.version>
|
||||
</properties>
|
||||
|
||||
<build>
|
||||
|
@ -311,8 +308,7 @@
|
|||
<dependency>
|
||||
<groupId>org.xerial</groupId>
|
||||
<artifactId>sqlite-jdbc</artifactId>
|
||||
<!-- <version>${sqlite-jdbc.version}</version>-->
|
||||
<version>3.41.2.1</version>
|
||||
<version>${sqlite-jdbc.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
|
Loading…
Reference in New Issue