Skip to content

Instantly share code, notes, and snippets.

@davelnewton
Created January 5, 2012 17:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davelnewton/1566181 to your computer and use it in GitHub Desktop.
Save davelnewton/1566181 to your computer and use it in GitHub Desktop.
Groovier groovy
/**
* Original with inline Groovier version
*/
//def publisher = null
//for (iter in project.getPublishersList()) {
// if (iter.getDescriptor().getDisplayName().equals("Editable Email Notification")) {
// publisher = iter
// break
// }
//}
publisher = project.publishersList.find { it.descriptor.displayName == "Editable Email Notification" }
if (publisher != null) {
//def logParserResult
//for (action in build.getActions()) {
// if (action.toString().contains("LogParserAction")) {
// logParserResult = action.getResult()
// break
// }
//}
logParserResult = build.actions.find { it.toString().contains "LogParserAction" }
def errorLinksFile = new File(logParserResult.getErrorLinksFile())
pattern = ~/<a.*?><font.*?>/
replaceWith = "<a href=\"${rootUrl}${build.url}parsed_console/?\">"
//def errorList = []
//for (line in errorLinksFile.getText().split("\n")) {
// if (!line.contains("href")) {
// continue
// }
// errorList.add(line.replaceAll(pattern, "<a href="+ rooturl + build.url + "parsed_console/?\">").minus("</font>"))
//}
errorList = errorLinksFile.readLines().grep { it.contains "href" }.collect { line ->
line.replaceAll(pattern, replaceWith).minus("</font>")
}
}
/**
* Just Groovier version.
*/
publisher = project.publishersList.find { it.descriptor.displayName == "Editable Email Notification" }
if (publisher != null) {
logParserResult = build.actions.find { it.toString().contains "LogParserAction" }
pattern = ~/<a.*?><font.*?>/
replaceWith = "<a href=\"${rootUrl}${build.url}parsed_console/?\">"
errorLinksFile = new File(logParserResult.getErrorLinksFile())
errorList = errorLinksFile.readLines().grep { it.contains "href" }.collect { line ->
line.replaceAll(pattern, replaceWith).minus("</font>")
}
}
@jimboca
Copy link

jimboca commented Mar 23, 2016

Using this in the groovy email template I get:

Exception raised during template rendering: No signature of method: hudson.plugins.logparser.LogParserAction.getErrorLinksFile() is applicable for argument types: () values: [] groovy.lang.MissingMethodException:

Also, the ${rootUrl} should be ${rooturl}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment