mirror of
https://github.com/openeggbert/bit-backup.git
synced 2025-03-25 15:37:53 +01:00
Added Jenkins support
This commit is contained in:
parent
72e5214000
commit
5280c45f04
114
Jenkinsfile
vendored
Normal file
114
Jenkinsfile
vendored
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
pipeline
|
||||||
|
/*
|
||||||
|
Bit Inspector
|
||||||
|
|
||||||
|
Requirements:
|
||||||
|
|
||||||
|
Maven is Installed
|
||||||
|
|
||||||
|
Java 21 is installed - variable JAVA_21_HOME is set
|
||||||
|
|
||||||
|
*/
|
||||||
|
{
|
||||||
|
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
|
||||||
|
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: "<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)"
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
pom.xml
4
pom.xml
@ -40,8 +40,6 @@
|
|||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<checkstyle.skip>true</checkstyle.skip><!-- TODO: make false-->
|
<checkstyle.skip>true</checkstyle.skip><!-- TODO: make false-->
|
||||||
<power.version>2.0.1-SNAPSHOT</power.version>
|
<power.version>2.0.1-SNAPSHOT</power.version>
|
||||||
<maven.compiler.source>19</maven.compiler.source>
|
|
||||||
<maven.compiler.target>19</maven.compiler.target>
|
|
||||||
<db-migration-core.version>0.1.1-SNAPSHOT</db-migration-core.version>
|
<db-migration-core.version>0.1.1-SNAPSHOT</db-migration-core.version>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
@ -112,7 +110,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
<artifactId>build-helper-maven-plugin</artifactId>
|
<artifactId>build-helper-maven-plugin</artifactId>
|
||||||
<version>3.2.0</version>
|
<version>${build-helper-maven-plugin.version}</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>add-resource</id>
|
<id>add-resource</id>
|
||||||
|
@ -40,7 +40,7 @@ import org.nanoboot.bitinspector.persistence.impl.sqlite.SqliteDatabaseMigration
|
|||||||
import org.nanoboot.dbmigration.core.main.MigrationResult;
|
import org.nanoboot.dbmigration.core.main.MigrationResult;
|
||||||
import org.nanoboot.powerframework.time.duration.Duration;
|
import org.nanoboot.powerframework.time.duration.Duration;
|
||||||
import org.nanoboot.powerframework.time.moment.LocalDateTime;
|
import org.nanoboot.powerframework.time.moment.LocalDateTime;
|
||||||
import org.nanoboot.powerframework.time.utils.RemainingTimeCalculator;
|
import org.nanoboot.powerframework.time.utils.ProgressTracker;
|
||||||
import org.nanoboot.powerframework.time.utils.TimeUnit;
|
import org.nanoboot.powerframework.time.utils.TimeUnit;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -348,7 +348,7 @@ public class CheckCommand implements Command {
|
|||||||
List<FsFile> filesToUpdateLastCheckDate = new ArrayList<>();
|
List<FsFile> filesToUpdateLastCheckDate = new ArrayList<>();
|
||||||
int contentAndModTimeWereChanged = 0;
|
int contentAndModTimeWereChanged = 0;
|
||||||
|
|
||||||
RemainingTimeCalculator rtc = new RemainingTimeCalculator(filesInDb.size() - filesToBeRemovedFromDb.size());
|
ProgressTracker progressTracker = new ProgressTracker(filesInDb.size() - filesToBeRemovedFromDb.size());
|
||||||
for (FsFile fileInDb : filesInDb) {
|
for (FsFile fileInDb : filesInDb) {
|
||||||
String absolutePathOfFileInDb = fileInDb.getAbsolutePath();
|
String absolutePathOfFileInDb = fileInDb.getAbsolutePath();
|
||||||
if (filesToBeRemovedFromDb.contains(fileInDb)) {
|
if (filesToBeRemovedFromDb.contains(fileInDb)) {
|
||||||
@ -356,12 +356,12 @@ public class CheckCommand implements Command {
|
|||||||
continue;
|
continue;
|
||||||
|
|
||||||
}
|
}
|
||||||
rtc.nextDone();
|
progressTracker.nextDone();
|
||||||
processedCount = processedCount + 1;
|
processedCount = processedCount + 1;
|
||||||
if (processedCount % 100 == 0) {
|
if (processedCount % 100 == 0) {
|
||||||
double progress = ((double) processedCount) / countOfFilesToCalculateHashSum * 100;
|
double progress = ((double) processedCount) / countOfFilesToCalculateHashSum * 100;
|
||||||
LOG.info("Update - Progress: " + processedCount + "/" + countOfFilesToCalculateHashSum + " " + String.format("%,.2f", progress) + "%");
|
LOG.info("Update - Progress: " + processedCount + "/" + countOfFilesToCalculateHashSum + " " + String.format("%,.2f", progress) + "%");
|
||||||
LOG.info("Remains: " + Duration.of(rtc.getRemainingSecondsUntilEnd(), TimeUnit.SECOND).toHumanString());
|
LOG.info("Remains: " + Duration.of(progressTracker.getRemainingSecondsUntilEnd(), TimeUnit.SECOND).toHumanString());
|
||||||
}
|
}
|
||||||
File file = new File("./" + absolutePathOfFileInDb);
|
File file = new File("./" + absolutePathOfFileInDb);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user