-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement Mustache templates for messages #32
base: master
Are you sure you want to change the base?
Conversation
Updated to use Jenkins 1.500 and added the Java implementation of Mustache from https://github.com/spullara/mustache.java
The plugin will now use Mustache template from configuration when creating HipChat notifications. This allows you to use any values available in the build / project configuration, including your own custom parameters.
When there is no config set there was an empty message being sent, instead make sure the defaults are used.
MessageBuilder is no longer required since we now generate messages using Mustache.
And some minor fixes to ensure there's no doubling up of "Started" text.
Previous code was incorrectly getting message templates from the global notifier instead of using the JobProperties object
Use a single "trigger" string that's the same as the non-Mustache version's string instead of separate cause & changes strings which could cause duplications.
If anyone wants to try the plugin with Mustache notification templates I have a snapshot HPI up in Dropbox: https://dl.dropbox.com/u/5336861/hipchat.hpi YMMV, disclaimer, etc, etc :-) Also check the updated README |
…s/jenkins-hipchat-plugin into feature-mustache-messages
If the build fails then the completion message may contain HTML. This means the default message needs to triple 'stache "status" so that the correct output is generated.
Any progress on accepting this? I would really like to add the description to my messages since i have "per PR" builds the number just becomes obsolete. |
@rdohms you can always run my snapshot HPI instead of the "official" one if you want the functionality now? Actually I should build a new one with the last 2 fixes in there, don't have time right now though. |
I am also interested in this. |
Nice work. Please add to master branch |
Inefficient use of concatenated strings with String builder when creating the link to the build job.
Style fix to check for blank strings based on feedback.
For all those that are interested, I've posted the latest snapshot HPI with these changes (based on at: https://dl.dropbox.com/u/5336861/hipchat.hpi I've been using this in production since I wrote it 2 months ago and haven't experienced any issues, although we do only have a small installation. |
I have another questions. Does your template replaces any parameter that are set by the build. Default parameter like $BUILD_ID and also custom parameter from a parameteriezed build? |
@phil-schneider - have a look at the README in my feature branch, it gives examples of how to access stuff about the build from the mustache templates: |
I installed this fork from the compiled https://dl.dropbox.com/u/5336861/hipchat.hpi link but for some reason I can't seem to customize the template. If I change either the global or project completion template I get an empty message (I just tried adding the word test into the template).
Notice the last line is missing the message. |
Interesting.. I'll look into it. On Tue, Apr 9, 2013 at 3:14 AM, Jeffrey Sambells
M. |
Actually it only seem sto be blank if I modify the project specific template. If I modify the global one it seems to ignore my settings and uses the default one. |
Also noticed that the global Build Server Url isn't applied in the Open link (everything lis linking as if it's a local file. It's like it's not reading my configuration. I'm running the latest version of Jenkins. |
From all those reports it looks like there's just an issue with applying Will try and reproduce when I have some time (maybe add some unit tests!) On Tue, Apr 9, 2013 at 11:13 AM, Jeffrey Sambells
M. |
Ya, possibly. Playing with it some more it seems editing the global config doesn't actually update the configs in jobs/ until after I delete and then re-added the hipchat phase. That fixed the Build Server URL but the custom messages still didn't work. |
I think this was an issue I ran into with the plugin before I made my On Tue, Apr 9, 2013 at 11:45 AM, Jeffrey Sambells
M. |
ok, still can't figure out why the templates don't work though. The global one is ignored and the local changes just cause it to be blank. Here's my test job config if you can shed any insight:
|
@marcins I just tested this. It seems that it works perfectly except for setting a custom template per project. When doing that (even the default one, or just plain text) it seems to not send the notification. Using the custom suffix seems to work. Also I would suggest adding some sort of logging so we can see the output in the build script (currently there is NO way to figure out why the messages aren't being sent if the template is wrong) |
There seem to be three (this one, #38, #42) pull requests all about customizing the sent message. This one seems most flexible and could probably cover the use cases of the other two, but I worry about it being able to cover the dead simple: "I just want to change the text string a little bit" case without someone having to read the Mustache docs. How do the other maintainers feel? |
I think this is the best solution, as the readme is quite clear on how to do it. It's the most flexible solution |
A number of people in issue #12 have asked for the ability to customise the messages, such as adding build parameters etc. By using Mustache templates for build messages this can now be done.
This is quite a large change, and probably not as heavily tested as it should be. It probably needs some unit tests too. I am also not a Java developer, but "know" the language, so I might not have done everything optimally.
The README has been updates with information as to how the templates work, and the defaults should keep the messages the same as they were pre-Mustache.
This doesn't actually solve the original issue as it doesn't add the git branch name, and if the branch name isn't available through the accessible instance variables then it won't, I haven't checked.
It's probably a good start though!