Tuesday, July 23, 2013

Appending HTML file as e-mail in Jenkins/Hudson

You need "Jenkins Email Extension Plugin", which could be installed from Jenkins/Hudson available plugins. Restart is needed.
 You need to fill "Project Recipient List, "Pre-send Script" and correct triggers.

"Pre-send Script"have to be something like this:

def reportPath = build.getWorkspace().child("test.html")
msg.setContent(reportPath.readToString(), "text/html");

2 comments:

  1. this is not working I get:
    groovy.lang.MissingPropertyException: No such property: msg for class: Script1
    at org.codehaus.groovy.runtime.ScriptBytecodeAdapter.unwrap(ScriptBytecodeAdapter.java:50)
    at org.codehaus.groovy.runtime.callsite.PogoGetPropertySite.getProperty(PogoGetPropertySite.java:49)
    at org.codehaus.groovy.runtime.callsite.AbstractCallSite.callGroovyObjectGetProperty(AbstractCallSite.java:231)
    at Script1.run(Script1.groovy:2)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:580)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:618)
    at groovy.lang.GroovyShell.evaluate(GroovyShell.java:589)
    at hudson.plugins.emailext.plugins.trigger.AbstractScriptTrigger.trigger(AbstractScriptTrigger.java:56)
    at hudson.plugins.emailext.ExtendedEmailPublisher._perform(ExtendedEmailPublisher.java:232)
    at hudson.plugins.emailext.ExtendedEmailPublisher.prebuild(ExtendedEmailPublisher.java:211)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:838)
    at hudson.model.AbstractBuild$AbstractBuildExecution.preBuild(AbstractBuild.java:833)
    at hudson.model.Build$BuildExecution.doRun(Build.java:142)
    at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:586)
    at hudson.model.Run.execute(Run.java:1597)
    at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:46)
    at hudson.model.ResourceController.execute(ResourceController.java:88)
    at hudson.model.Executor.run(Executor.java:247)

    ReplyDelete
  2. which is your "Email-ext plugin" version. I have 2.30.2. Try updating, if you are with older and keep me in touch.

    ReplyDelete