Developing Jenkins post-build plugin
Asked Answered
E

2

6

I am currently developing a simple plugin that retrieves results from a Jenkins build. I am extending Notifier and using build.getResults() to get the information. However, when I upload my plugin, I can't set it as a post-build action.
When I run my builds, they break on build.getResults() since I am trying to get the results while the build is still running.

What can I do to properly get the build result ?

Eldwun answered 9/10, 2012 at 21:3 Comment(0)
A
2

Best thing is to look at existing plugins which use Notifier extension point (click to expand implementing plugins list).

Check that you have the Descriptor implemenation (inner) class, as well as config.jelly. Also check jenkins.out and jenkins.err logs for any exceptions (such as malformed config.jelly).

Edit: Actually, Notifier subclass of this plugin looks really simple as Notifiers go: https://wiki.jenkins-ci.org/display/JENKINS/The+Continuous+Integration+Game+plugin , see especially its GamePublisher.java and corresponding config.jelly, and it's GameDescriptor.java, which has been made a full outer class (often descriptor is inner class). Also if you want options into Jenkins' Global configuration, you need a global.jelly, but if you don't have such options, that is something you can just leave out (unlike config.jelly, which you must have for Notifier even if it is empty, like here).

As a general note, it can be really annoying when things do not work, and you do not get any error, your stuff simply is just not displayed by Jenkins... If you just want to get things to work for you, using Groovy build step might be easier, but if you want to get things to work for others, then doing a decent full plugin reduces support requests.

Affianced answered 27/1, 2013 at 15:22 Comment(0)
E
1

Since this sounds so simple, are you sure you need a plugin ? Take a look at using a Groovy Postbuild step instead; they're much easier to write. There are some good usage examples in the link. If you decide you really need a plugin, see if you can extend an existing one rather than writing your own; it's an easier way to understand the ins and outs of Jenkins plugin writing.

Eisk answered 9/10, 2012 at 22:6 Comment(3)
I've been using the Groovy Postbuild plugin to invoke a secure web service (exposed by Coverity Connect 6.5.3) and have been having problems with the entire Jenkins JVM running out of PermGen (JDK 1.7 update 15). Up until now, the Groovy Postbuild plugin has worked fine for invoking a SonarQube's REST services. In summary, just beware that the Groovy Postbuild plugin may have limits.Toolmaker
This answer should provide examples of how to do this, before suggesting the use of an existing plugin.Puppis
@JohnZeller there are plenty of usage examples in the link I provided, but I've edited the answer to make that clearer.Eisk

© 2022 - 2024 — McMap. All rights reserved.