Skip to content

Commit

Permalink
Merge branch 'master' into to/#98-fat-jar
Browse files Browse the repository at this point in the history
  • Loading branch information
t-ober authored Oct 12, 2022
2 parents 381879e + ee96fbc commit 264f545
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 131 deletions.
120 changes: 3 additions & 117 deletions Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,6 @@
// general config values
////////////////////////////////


//// Rocket.Chat channel to publish updates
final String rocketChatChannel = "jenkins"


//// project build dir order
//// this list contains the build order
//// normally it *should* start with the project under investigation
Expand Down Expand Up @@ -93,12 +88,6 @@ if (env.BRANCH_NAME == "master") {

// deployment only
if (params.triggered == "true") {
// notify rocket chat about the started master branch deployment
rocketSend attachments: [],
channel: rocketChatChannel,
message: ":jenkins_triggered:\n" +
"*deploy* manually triggered on master branch of ${projects.get(0)}."
rawMessage: true

node {
// This displays colors using the 'xterm' ansi color map.
Expand Down Expand Up @@ -137,32 +126,17 @@ if (env.BRANCH_NAME == "master") {

/**
* Post processing
* Publish reports and notify rocket chat
* Publish reports
* Future clean workspace processes should be declared here
*/
stage('post processing') {
// publish reports
// publishReports()

// notify rocket chat about success
String buildMode = "deploy"
String branchName = params.pull_request_head_label

rocketSend attachments: [
[$class: 'MessageAttachment', color: 'green', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_party: \n" +
"${buildMode} successful!\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${branchName} \n" +
"*deployedArtifacts:* ${deployedArtifacts}\n"
rawMessage: true

// set build to successfull
currentBuild.result = 'SUCCESS'
}


}

} catch (Exception exc) {
Expand All @@ -171,18 +145,6 @@ if (env.BRANCH_NAME == "master") {
String buildMode = "deploy"
String branchName = params.pull_request_head_label

// notify rocketchat about failure
rocketSend attachments: [
[$class: 'MessageAttachment', color: 'red', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_explode: \n" +
"${buildMode} failed!\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${branchName} \n" +
"*errorMessage:* ${stageErrorMessage}\n" +
"See logs for details.",
rawMessage: true

// publish reports even on failure
publishReports()

Expand All @@ -195,13 +157,6 @@ if (env.BRANCH_NAME == "master") {
} else {

// merge into master
// notify rocket chat about the started master branch deployment
rocketSend attachments: [],
channel: rocketChatChannel,
message: ":jenkins_triggered:\n" +
"*deploy* triggered by merge ${params.pull_request_title} into master of ${projects.get(0)}."
rawMessage: true

node {
// This displays colors using the 'xterm' ansi color map.
ansiColor('xterm') {
Expand Down Expand Up @@ -282,27 +237,12 @@ if (env.BRANCH_NAME == "master") {

/**
* Post processing
* Publish reports and notify rocket chat
* Publish reports
* Future clean workspace processes should be declared here
*/
stage('post processing') {
// publish reports
publishReports()

// notify rocket chat about success
String buildMode = "merge"
String branchName = params.pull_request_head_label

rocketSend attachments: [
[$class: 'MessageAttachment', color: 'green', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_party: \n" +
"${buildMode} successful!\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${branchName} \n" +
"*deployedArtifacts:* ${deployedArtifacts}\n"
rawMessage: true

}

} catch (exc) {
Expand All @@ -315,18 +255,6 @@ if (env.BRANCH_NAME == "master") {
buildMode = ""
}

// notify rocketchat about failure
rocketSend attachments: [
[$class: 'MessageAttachment', color: 'red', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_explode: \n" +
"${buildMode} failed!\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${branchName} \n" +
"*errorMessage:* ${stageErrorMessage}\n" +
"See logs for details.",
rawMessage: true

// publish reports even on failure
publishReports()

Expand Down Expand Up @@ -365,26 +293,8 @@ if (env.BRANCH_NAME == "master") {

/// if the pipeline is scanned we don't want to execute anything
if (params.triggered == "true") {
// notify rocket chat about the started master branch deployment
rocketSend attachments: [],
channel: rocketChatChannel,
message: ":jenkins_triggered:\n" +
"*PR test* manually triggered on master branch of ${projects.get(0)}."
rawMessage: true

log(i, "PR test manually triggered by user.")

} else {
// notify rocket chat about the started PR run
rocketSend attachments: [],
channel: rocketChatChannel,
message: ":jenkins_triggered:\n" +
"*forcedPR* triggered with parameters:\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${params.issue_title}\n" +
"*triggeredBy:* ${params.sender_login}",
rawMessage: true

log(i, "forced PR triggered by webhook. Parameters are:")
log(i, "issue_title: ${params.issue_title}")
log(i, "comment_body: ${params.comment_body}")
Expand Down Expand Up @@ -439,24 +349,12 @@ if (env.BRANCH_NAME == "master") {

/**
* Post processing
* Publish reports and notify rocket chat
* Publish reports
* Future clean workspace processes should be declared here
*/
stage('post processing') {
// publish reports
publishReports()

// notify rocket chat about success
String buildMode = "forcedPR"

rocketSend attachments: [
[$class: 'MessageAttachment', color: 'green', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_party: \n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"${buildMode} successful!\n" +
"*branch:* ${featureBranchName}"
rawMessage: true
}

} catch (Exception exc) {
Expand All @@ -471,18 +369,6 @@ if (env.BRANCH_NAME == "master") {

println("[ERROR] [${date.format("dd/MM/yyyy")} - ${date.format("HH:mm:ss")}]" + exc)

// notify rocketchat about failure
rocketSend attachments: [
[$class: 'MessageAttachment', color: 'red', title: 'go to logs', titleLink: env.BUILD_URL],],
channel: rocketChatChannel,
message: ":jenkins_explode: \n" +
"${buildMode} failed!\n" +
"*repo:* ${urls.get(0)}/${projects.get(0)}\n" +
"*branch:* ${branchName} \n" +
"*errorMessage:* ${stageErrorMessage}\n" +
"See logs for details.",
rawMessage: true

// publish reports even on failure
publishReports()

Expand Down
20 changes: 10 additions & 10 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import com.github.jengelman.gradle.plugins.shadow.transformers.AppendingTransfor
import com.github.jengelman.gradle.plugins.shadow.transformers.Log4j2PluginsCacheFileTransformer

plugins {
id "com.jfrog.artifactory" version "4.24.20" //artifactory support
id "com.jfrog.artifactory" version "4.28.3" //artifactory support
id 'groovy' // groovy support
id 'java' // java support
id 'application' // creates a JVM executable
id 'maven-publish' // publish to a maven repo (local or mvn central, has to be defined)
id 'pmd' // code check, working on source code
id 'com.github.spotbugs' version '4.7.8' // code check, working on byte code
id 'com.diffplug.spotless' version '5.17.0'// code format
id 'com.github.spotbugs' version '5.0.7' // code check, working on byte code
id 'com.diffplug.spotless' version '6.7.0'// code format
id 'com.simonharrer.modernizer' version '2.1.0-1' // detect deprecated APIs
id 'com.github.onslip.gradle-one-jar' version '1.0.6' // pack a self contained jar
id 'jacoco' // java code coverage plugin
Expand All @@ -20,8 +20,8 @@ plugins {
ext {
//version (changing these should be considered thoroughly!)
hibernateVersion = '5.3.3.Final'
log4jVersion = '2.17.1'
picoliVersion = '4.6.1'
log4jVersion = '2.17.2'
picoliVersion = '4.6.3'
javaVersion = JavaVersion.VERSION_17

scriptsLocation = 'gradle' + File.separator + 'scripts' + File.separator //location of script plugins
Expand Down Expand Up @@ -61,12 +61,12 @@ dependencies {

//JAXB (needed for hibernate, but not longer contained in JDK9+)
implementation 'javax.xml.bind:jaxb-api:2.3.1'
implementation 'com.sun.xml.bind:jaxb-core:3.0.2'
implementation 'com.sun.xml.bind:jaxb-impl:3.0.2'
implementation 'com.sun.xml.bind:jaxb-core:4.0.0'
implementation 'com.sun.xml.bind:jaxb-impl:4.0.0'
implementation 'javax.activation:activation:1.1.1'

//database
implementation 'org.postgresql:postgresql:42.2.24'
implementation 'org.postgresql:postgresql:42.3.6'
implementation 'javax.persistence:javax.persistence-api:2.2'

// logging
Expand All @@ -78,11 +78,11 @@ dependencies {
implementation 'org.jetbrains:annotations:23.0.0'
annotationProcessor "info.picocli:picocli-codegen:$picoliVersion"
implementation "info.picocli:picocli:$picoliVersion"
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.0'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'

//tests
testImplementation 'junit:junit:4.+'
testImplementation 'org.testcontainers:postgresql:1.16.0'
testImplementation 'org.testcontainers:postgresql:1.17.2'

}

Expand Down
12 changes: 9 additions & 3 deletions src/main/java/edu/ie3/tools/Converter.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public class Converter implements Runnable {
private final ExecutorService fileEraserExecutor =
Executors.newFixedThreadPool((int) Math.ceil(noOfProcessors / 3d));

/** @return timestamp for logging output (e.g "MR 09.10.2018 18:00 - TS 01 | ") */
/**
* @return timestamp for logging output (e.g "MR 09.10.2018 18:00 - TS 01 | ")
*/
public static String getFormattedTimestep(@NotNull ZonedDateTime modelrun, int timestep) {
return "MR "
+ MODEL_RUN_FORMATTER.format(modelrun)
Expand All @@ -59,12 +61,16 @@ public static String getFormattedTimestep(@NotNull ZonedDateTime modelrun, int t
+ " | ";
}

/** @return timestamp for logging output (e.g "MR 09.10.2018 18:00 | ") */
/**
* @return timestamp for logging output (e.g "MR 09.10.2018 18:00 | ")
*/
public static String getFormattedModelrun(@NotNull ZonedDateTime modelrun) {
return "MR " + MODEL_RUN_FORMATTER.format(modelrun) + " | ";
}

/** @return timestamp for logging output (e.g "MR 09.10.2018 18:00 - TS 01 | ") */
/**
* @return timestamp for logging output (e.g "MR 09.10.2018 18:00 - TS 01 | ")
*/
public static String getFormattedTimestep(@NotNull FileModel file) {
return getFormattedTimestep(file.getModelrun(), file.getTimestep());
}
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/edu/ie3/tools/Downloader.java
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ public Downloader() {
dbController = new DatabaseController(PERSISTENCE_UNIT_NAME, validateConnectionProperties());
}

/** @return if a connection to given url could be established */
/**
* @return if a connection to given url could be established
*/
public static boolean isUrlReachable(String url) {
HttpURLConnection.setFollowRedirects(false);
HttpURLConnection con;
Expand Down

0 comments on commit 264f545

Please sign in to comment.