I have a grails project and I use hudson to follow different analysis. I want to send the report analysis (cobertura, codenarc, findbug) to the developer. However, I don't know how to use hudson's ext-mail. Through googling I suspect the solution is to use jelly sscript but I can seem to get it to work.
If the default jelly templates don't have everything you need in them, you can customize them without much effort.
Grab a copy of the default template: Default Jelly Templates
Modify it as needed
Place a copy in JENKINS_HOME\email-templates (create the dir if needed)
Configure the build to utilize the new template. If your new script is ensienne.jelly, the email content would look like this ${JELLY_SCRIPT,template="ensienne"}.
Side Note: Hudson was renamed to Jenkins a while back.
Also, here is a good resource for the email-ext plugin: Email-ext wiki
Related
When I create a jenkins job via the API, I use a previous job's config.xml, make my modifications and then make the POST call to create the job.
My questions is, is there a way to generate this programmatically? I.e. is there a structure of a config.xml, what XML entities it should have, what values, etc so I can write a small module to generate one and send it to the jenkins API call?
I don't think there's any mandatory XML entities. Submitting an empty structure should result in a job that has default values for all settings.
What you want to do is exactly what's done by the Jenkins Job Builder. It provides a YAML-based framework for creating Job configuration XML files and submitting them to Jenkins. It's a common alternative to the Job DSL plugin. I wouldn't recommend to re-implement such a solution yourself -- handling all the plugin-specific XML configuration parts will be a nightmare.
We create our jobs using Job DSL plugin. You can try the playground http://job-dsl.herokuapp.com/.
At first, it seems that it is hard to learn, but after the first seed job, it is much better.
When we started writing our scripts we were afraid that there will not be suitable API methods for our needs. It turned out that we had one such case, which was solved using the configure block.
Get started guide here.
Previously, I used testlink. This plugin generated a nice table with the test results in the build summary view.
Now, I don't use testlink anymore, so this plugin cannot be used. But instead, I want to feed a html report (which I take care of generating) to the build summary view.
I tried HTML Publisher Plugin, but it makes a link instead of displaying in the build summary view.
Is there such a plugin that allows me to specify that a certain .html file from the workspace will be included?
Bonus question: or even a plugin that allows a .html fragment to avoid the use of i-frames?
Try using the Summary Display Plugin. It work pretty good.
The configuration is a bit tricky so I'm adding an example screenshot of my configuration.
I have groovy email template(for Selenium Robot framework test execution) for Jenkins. Jenkins master is controlled by a remote team. So for placing this template in $JENKINS_HOME/email-templates, we need to raise a ticket and wait from 2 to 3 days. Also we expect, there might be changes required in template. So we are planning to put our templates inside our source code repository (GIT). so in the Jenkins test job, we checkout the test script together with email templates.
How to instruct Jenkins to look for the template in workspace folder instead of $JENKINS_HOME/email-templates in Jenkins Master
Sadly it seems you would need to modify the email-ext plugin as the search path is hardcoded into it.
You can see it here, check the occurrence on line 69 in file src/main/java/hudson/plugins/emailext/EmailExtTemplateAction.java
Changing it to another path would be trivial, however adding multiple locations you'd probably have to put some work in.
Edit: I wonder if it would be possible to put the wanted stuff into some txt file as a build step, and then load it into the mail content via some template configuration. If you have access to the job configuration this might be worth checking.
You can copy the template into the build workspace (e.g. with SCM step), and then email-ext can reach it:
${SCRIPT, template="${WORKSPACE}/foo.template"}
Is it possible to configure a "Job Template" (this is a particular kind of Jenkins item) with the groovy template coming from SCM as is possible in other job types? I don't see it as an option in ours, but perhaps there is another plugin required for this?
There is not such an option. The closest equivalent would be to create a job template using the Pipeline transformer, where the inline script is merely boilerplate running a load step to load the “real” code. (An existing RFE CJP-1718 suggests removing the need for this boilerplate; if that would be useful to you, file a support ticket mentioning it.)
Using Jenkins and email-ext, I have copied the "html" template and made it look the way I want for our build mail.
What I'd like to do now is get some custom metrics in the build mail. Specifically, our build jobs call a number of PHP scripts that perform work. One of these scripts creates a bunch of files in a directory. I'd like to have our build mail have an output line like:
The super cool script created 8 files for your enjoyment.
The PHP script knows it created 8 files, of course. How could that script get that number in a place where Jelly could know it and output it? Is there a way to have Jenkins store such things and make them available to the Jelly template?
Use the EnvInject Plugin https://wiki.jenkins-ci.org/display/JENKINS/EnvInject+Plugin
Set the Enviroment variable in your PHP script
Output the Environment Variable in your Email-Ext
If the files are created in a specific directory - so counting the number of files in a folder is good enough -, you could try something like this in your jelly template (note: I didn't test it):
<j:set var="filesCreated" value="${build.getWorkspace().child('path/to/result/dir').list().size()}"/>
The super cool script created ${filesCreated} files for your enjoyment.