简体   繁体   English

开发Jenkins post-build插件

[英]Developing Jenkins post-build plugin

I am currently developing a simple plugin that retrieves results from a Jenkins build. 我目前正在开发一个简单的插件,可以从Jenkins构建中检索结果。 I am extending Notifier and using build.getResults() to get the information. 我正在扩展Notifier并使用build.getResults()来获取信息。 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. 当我运行我的构建时,它们会在build.getResults()上中断,因为我在构建仍在运行时尝试获取结果。

What can I do to properly get the build result ? 我该怎么做才能正确获得构建结果?

Best thing is to look at existing plugins which use Notifier extension point (click to expand implementing plugins list). 最好的方法是查看使用Notifier扩展点的现有插件 (单击以展开实现插件列表)。

Check that you have the Descriptor implemenation (inner) class, as well as config.jelly. 检查您是否具有Descriptor实现(内部)类以及config.jelly。 Also check jenkins.out and jenkins.err logs for any exceptions (such as malformed config.jelly). 还要检查jenkins.out和jenkins.err日志中的任何异常(例如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). 编辑:实际上,这个插件的Notifier子类看起来很简单,因为Notifiers去了: https//wiki.jenkins-ci.org/display/JENKINS/The+Continuous+Integration+Game+plugin ,特别参见它的GamePublisher.java和相应的config.jelly ,它是GameDescriptor.java ,它已经成为一个完整的外部类(通常描述符是内部类)。 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). 此外,如果你想要选择Jenkins的全局配置,你需要一个global.jelly ,但是如果你没有这样的选项,那就是你可以省略的东西(不像config.jelly,你必须拥有Notifier,即使它是空的,就像这里一样)。

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. 作为一般说明,当事情不起作用时,它可能真的很烦人,你没有得到任何错误,你的东西只是Jenkins没有显示...如果你只想让事情适合你,使用Groovy构建步骤可能更容易,但如果你想让其他人工作,那么做一个体面的完整插件可以减少支持请求。

Since this sounds so simple, are you sure you need a plugin ? 由于这听起来很简单,你确定需要一个插件吗? Take a look at using a Groovy Postbuild step instead; 看一下使用Groovy Postbuild步骤 ; 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. 这是一种更容易理解Jenkins插件编写的细节。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM