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 ?
This plugin allows the user to execute a shell/batch task depending on the build log output. Java regular expression are allowed. This feature allows user to associate shell or a batch scripts that perform some tasks on Jenkins depending on the build log output.
Annotation Type DataBoundConstructorDesignates the constructor to be created from methods like StaplerRequest. bindJSON(Class, JSONObject) and StaplerRequest. bindParameters(Class, String) .
Jenkins plugins work by creating or extending an extension point, which hooks into a specific part of the build process. The catch: these extension points can differ significantly in what they do and how they work.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With