Last active
May 9, 2016 18:37
-
-
Save kulmam92/2236ce649262b896b7f8dd9f35f4a620 to your computer and use it in GitHub Desktop.
Display last changed log file in the workspace of Jenkins build - parameter : workSpace -> $workspace
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def myWorkdSpace = "$workSpace" | |
def files = buildFileList(myWorkdSpace) | |
def buildFileList(dirname) { | |
def files = [:] | |
def dir = new File(dirname) | |
if( dir.directory ) { | |
dir.listFiles().each { | |
def path = it.absolutePath | |
if( it.directory ) { | |
files << buildFileList(it.absolutePath) | |
} else if( path.matches('.+\\.log') ) { | |
files[it.absolutePath] = it.lastModified() | |
} | |
} | |
} | |
return files | |
} | |
println "Discovered ${files.size()} files:" | |
def modifiedTime = 0 | |
def newestModified | |
files.each { filename, modified -> | |
if(modified > modifiedTime) { | |
modifiedTime = modified | |
newestModified = filename | |
} | |
println "file '${filename}' '${modified}' found" | |
} | |
if(newestModified) { | |
println "" | |
println "############################################################" | |
println "Last modified log file is '${newestModified}'" | |
println "############################################################" | |
File file = new File(newestModified) | |
def linecount = file.readLines().size()-1 | |
def topcount = 10 | |
def i = linecount-topcount | |
while (i<=linecount) { | |
println file.readLines().get(i) | |
i++ | |
} | |
println "############################################################" | |
println "End of Last modified log file" | |
println "############################################################" | |
println "" | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(manager.logContains("^Build FAILED.")) { | |
manager.buildFailure() | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
${BUILD_LOG, maxLines=50, escapeHtml=false} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment