Skip to content

Commit

Permalink
Merge pull request #4474 from /issues/4443
Browse files Browse the repository at this point in the history
Notification email template with log output: use blank when not included
  • Loading branch information
gschueler committed Feb 19, 2019
2 parents 3793ab0 + 6f21ee3 commit 3a5dddc
Showing 1 changed file with 17 additions and 9 deletions.
Expand Up @@ -324,15 +324,23 @@ public class NotificationService implements ApplicationContextAware{
def template = new File(templatePath)
if (template.isFile()) {

if(attachlogbody){
if(template.text.indexOf('${logoutput.data}')>0){
outputBuffer=copyExecOutputToStringBuffer(exec,isFormatted)

//add to context in order to display output using a custom template ( using ${logoutput.data} )
def contextOutput=[:]
contextOutput['logoutput'] = ["data":outputBuffer.toString().encodeAsSanitizedHTML()]
context = DataContextUtils.merge(context, contextOutput)
}
//check if the custom template is calling ${logoutput.data}
def templateLogOutput=false
if(template.text.indexOf('${logoutput.data}')>=0){
templateLogOutput=true
}
def contextOutput=[:]
if(attachlogbody && templateLogOutput){
//just attached the output if the template uses ${logoutput.data}
outputBuffer=copyExecOutputToStringBuffer(exec,isFormatted)
contextOutput['logoutput'] = ["data":outputBuffer.toString().encodeAsSanitizedHTML()]
}else if(templateLogOutput) {
// add null value if template uses ${logoutput.data} and the attachlogbody is disabled
contextOutput['logoutput'] = ["data":""]
}

if(!contextOutput.isEmpty()) {
context = DataContextUtils.merge(context, contextOutput)
}

if (template.name.endsWith('.md') || template.name.endsWith('.markdown')) {
Expand Down

0 comments on commit 3a5dddc

Please sign in to comment.