Add all missing Jenkinsfiles

This commit is contained in:
2023-04-10 12:49:47 +02:00
parent 3b3f8e7162
commit 6e82e05298
5 changed files with 396 additions and 0 deletions

View File

@@ -0,0 +1,73 @@
pipeline {
agent any
stages {
stage('Restore tlw-database-tool') {
steps {
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
}
}
stage('Execute') {
steps {
script {
String jdkPath = tool name: 'OpenJDK15', type: 'jdk'
withCredentials([usernamePassword(credentialsId: 'aws', passwordVariable: 'AWS_SECRET_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
withEnv(["JAVA_HOME=${jdkPath}/jdk-15","AWS_SECRET_KEY=${AWS_SECRET_KEY}", "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"]) {
try {
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode APIFootballUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesListGistUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
} catch (Exception e) {
telegramSendManual("TLW-Database-Tool crashed!")
}
String output = readFile 'log.txt'
if(output != "") {
output = clean(output)
output.split('\n').each {
telegramSendManual(it)
}
}
}
}
}
}
}
stage('Trigger Tool') {
steps {
build wait: false, job: 'TippligaUpdater${season}'
build wait: false, job: 'WTLPokalUpdater${season}'
}
}
}
post {
always {
deleteDir()
}
failure {
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
}
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
}
return orig
}
def telegramSendManual(String text) {
def encodedMessage = URLEncoder.encode(text, "UTF-8")
println encodedMessage
httpRequest(
httpMode: 'GET',
contentType: 'APPLICATION_JSON',
responseHandle: 'NONE',
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
wrapAsMultipart: false,
consoleLogResponseBody: true
)
sleep 1
}

View File

@@ -0,0 +1,66 @@
pipeline {
agent any
stages {
stage('Restore tlw-database-tool') {
steps {
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
}
}
stage('GetAndWriteChecksum') {
steps {
script {
String jdkPath = tool name: 'OpenJDK18', type: 'jdk'
withCredentials([usernamePassword(credentialsId: 'aws', passwordVariable: 'AWS_SECRET_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
withEnv(["JAVA_HOME=${jdkPath}/jdk-18.0.1.1","AWS_SECRET_KEY=${AWS_SECRET_KEY}", "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"]) {
String checksum_tippliga = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode PostChecksum --season ${season} --league 1 --configFile Tippliga 2>&1"
writeFile file: 'checksum_tippliga.txt', text: checksum_tippliga
archiveArtifacts artifacts: 'checksum_tippliga.txt', followSymlinks: false
String checksum_wtlpokal = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode PostChecksum --season ${season} --league 1 --configFile WTL-Pokal 2>&1"
writeFile file: 'checksum_wtlpokal.txt', text: checksum_wtlpokal
archiveArtifacts artifacts: 'checksum_wtlpokal.txt', followSymlinks: false
}
}
}
}
}
stage('CompareChecksums') {
steps {
copyArtifacts filter: 'checksum*', fingerprintArtifacts: true, projectName: 'CheckGistUpdates', selector: lastWithArtifacts(), target: 'last'
script {
String checksumTippliga = readFile 'checksum_tippliga.txt'
String lastChecksumTippliga = readFile 'last/checksum_tippliga.txt'
String checksumWTLPokal = readFile 'checksum_wtlpokal.txt'
String lastChecksumWTLPokal = readFile 'last/checksum_wtlpokal.txt'
if(!checksumTippliga.equals(lastChecksumTippliga)){
telegramSendManual('Tippliga Update')
build wait: false, job: 'TippligaUpdater'
}
if(!checksumWTLPokal.equals(lastChecksumWTLPokal)){
telegramSendManual('WTL-Pokal Update')
build wait: false, job: 'WTLPokalUpdater'
}
}
}
}
}
post {
failure {
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
}
}
}
def telegramSendManual(String text) {
sleep 1
def encodedMessage = URLEncoder.encode(text, "UTF-8")
println encodedMessage
httpRequest(
httpMode: 'GET',
contentType: 'APPLICATION_JSON',
responseHandle: 'NONE',
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
wrapAsMultipart: false,
consoleLogResponseBody: true
)
}

View File

@@ -0,0 +1,89 @@
pipeline {
agent any
stages {
stage('Restore tlw-database-tool') {
steps {
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
}
}
stage('Execute') {
steps {
script {
String jdkPath = tool name: 'OpenJDK', type: 'jdk'
withCredentials([usernamePassword(credentialsId: 'aws', passwordVariable: 'AWS_SECRET_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
withEnv(["JAVA_HOME=${jdkPath}/jdk-15","AWS_SECRET_KEY=${AWS_SECRET_KEY}", "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"]) {
String outputBuild = ""
String output = ""
String errorOutput = ""
String outputTemp = ""
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 45 --configFile Supercup 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 45 --configFile Supercup 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 45 --configFile Supercup 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
if(output != "") {
output = clean(output)
output.split('\n').toList().unique().each {
telegramSendManual(it)
}
}
if(errorOutput != "") {
errorOutput = clean(errorOutput)
errorOutput.split('\n').toList().unique().each {
telegramSendManual(it)
}
}
}
}
}
}
}
stage('CleanUp') {
steps {
deleteDir()
}
}
}
post {
failure {
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
}
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
}
return orig
}
def telegramSendManual(String text) {
def encodedMessage = URLEncoder.encode(text, "UTF-8")
println encodedMessage
httpRequest(
httpMode: 'GET',
contentType: 'APPLICATION_JSON',
responseHandle: 'NONE',
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
wrapAsMultipart: false,
consoleLogResponseBody: true
)
}

View File

@@ -0,0 +1,74 @@
pipeline {
agent any
stages {
stage('Restore tlw-database-tool') {
steps {
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
}
}
stage('Execute') {
steps {
script {
String jdkPath = tool name: 'OpenJDK18', type: 'jdk'
withCredentials([usernamePassword(credentialsId: 'aws', passwordVariable: 'AWS_SECRET_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
withEnv(["JAVA_HOME=${jdkPath}/jdk-18.0.1.1", "AWS_SECRET_KEY=${AWS_SECRET_KEY}", "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"]) {
try {
sh "ls build/libs"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 1 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
sh "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 2 --configFile Tippliga 2>&1 >> log.txt"
} catch (Exception e) {
telegramSendManual("TLW-Database-Tool crashed!")
}
String output = readFile 'log.txt'
if(output != "") {
output = clean(output)
output.split('\n').toList().unique().each {
telegramSendManual(it)
}
}
}
}
}
}
}
}
post {
always {
deleteDir()
}
failure {
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
}
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91.App - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91.App - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
}
return orig
}
def telegramSendManual(String text) {
sleep 1
if(text) {
def encodedMessage = URLEncoder.encode(text, "UTF-8")
println encodedMessage
httpRequest(
httpMode: 'GET',
contentType: 'APPLICATION_JSON',
responseHandle: 'NONE',
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
wrapAsMultipart: false,
consoleLogResponseBody: true
)
}
}

View File

@@ -0,0 +1,94 @@
pipeline {
agent any
stages {
stage('Restore tlw-database-tool') {
steps {
copyArtifacts filter: '**/tlw-database-tool-1.0.jar', fingerprintArtifacts: true, projectName: 'build tlw-database-tool', selector: lastSuccessful(), target: '.'
}
}
stage('Execute') {
steps {
script {
String jdkPath = tool name: 'OpenJDK18', type: 'jdk'
withCredentials([usernamePassword(credentialsId: 'aws', passwordVariable: 'AWS_SECRET_KEY', usernameVariable: 'AWS_ACCESS_KEY_ID')]) {
withEnv(["JAVA_HOME=${jdkPath}/jdk-18.0.1.1","AWS_SECRET_KEY=${AWS_SECRET_KEY}", "AWS_ACCESS_KEY_ID=${AWS_ACCESS_KEY_ID}"]) {
String outputBuild = ""
String output = ""
String errorOutput = ""
String outputTemp = ""
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchesUpdaterFootball --season ${season} --league 48 --configFile WTL-Pokal 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode MatchdaysUpdater --season ${season} --league 48 --configFile WTL-Pokal 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
try {
outputTemp = sh returnStdout: true, script: "java -jar build/libs/tlw-database-tool-1.0.jar --mode TeamsUpdater --season ${season} --league 48 --configFile WTL-Pokal 2>&1"
output += outputTemp
} catch (Exception e) {
errorOutput += outputTemp
}
if(output != "") {
output = clean(output)
output.split('\n').toList().unique().each {
telegramSendManual(it)
}
}
if(errorOutput != "") {
errorOutput = clean(errorOutput)
errorOutput.split('\n').toList().unique().each {
telegramSendManual(it)
}
}
}
}
}
}
}
stage('CleanUp') {
steps {
deleteDir()
}
}
}
post {
failure {
telegramSendManual("Build failed!\n${env.BUILD_URL}console")
}
}
}
private String clean(String orig) {
orig = orig.replace("\n\n", "\n")
while(orig.indexOf(" [main] INFO de.jeyp91 - ") > 0) {
int index = orig.indexOf(" [main] INFO de.jeyp91 - ")
String newString = orig.substring(0, index-12) + orig.substring(index+30, orig.size())
orig = newString
}
while(orig.indexOf(" [main] ERROR de.jeyp91 - ") > 0) {
int index = orig.indexOf(" [main] ERROR de.jeyp91 - ")
String newString = orig.substring(0, index-12) + orig.substring(index+31, orig.size())
orig = newString
}
return orig
}
def telegramSendManual(String text) {
def encodedMessage = URLEncoder.encode(text, "UTF-8")
println encodedMessage
httpRequest(
httpMode: 'GET',
contentType: 'APPLICATION_JSON',
responseHandle: 'NONE',
url: "https://api.telegram.org/bot1298223079:AAEplcQpfzFG59qNYAYuSbJKtB9HMXCCE_U/sendMessage?text=$encodedMessage&chat_id=459231986&disable_web_page_preview=true",
wrapAsMultipart: false,
consoleLogResponseBody: true
)
}