Improve logging to telegram
This commit is contained in:
28
jenkinsfiles/TippligaUpdater/Jenkinsfile
vendored
28
jenkinsfiles/TippligaUpdater/Jenkinsfile
vendored
@@ -24,10 +24,11 @@ pipeline {
|
||||
} catch (Exception e) {
|
||||
telegramSendManual("TLW-Database-Tool crashed!")
|
||||
}
|
||||
String output = readFile 'log.txt'
|
||||
if(output != "") {
|
||||
output = clean(output)
|
||||
output.split('\n').toList().unique().each {
|
||||
String outputString = readFile 'log.txt'
|
||||
if(outputString != "") {
|
||||
ArrayList<String> outputList = outputString.replace("\n\n", "\n").split('\n').toList()
|
||||
outputList = clean(outputList)
|
||||
outputList.each {
|
||||
telegramSendManual(it)
|
||||
}
|
||||
}
|
||||
@@ -47,14 +48,19 @@ pipeline {
|
||||
}
|
||||
}
|
||||
|
||||
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
|
||||
private ArrayList<String> clean(ArrayList<String> orig) {
|
||||
ArrayList<String> cleaned = new ArrayList<String>()
|
||||
orig.each{line ->
|
||||
if(line.indexOf(" [main] INFO de.jeyp91 - ") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
|
||||
if(line.indexOf(" [main] ERROR de.jeyp91") >= 0) {
|
||||
line = line.substring(20, line.size())
|
||||
}
|
||||
cleaned.add(line)
|
||||
}
|
||||
return orig
|
||||
return cleaned.unique()
|
||||
}
|
||||
|
||||
def telegramSendManual(String text) {
|
||||
|
||||
Reference in New Issue
Block a user