Groovy Postbuild Plugin: Access Jenkins and not Hudson instance

63 views
Skip to first unread message

Sverre Moe

unread,
Mar 4, 2015, 8:02:58 AM3/4/15
to jenkins...@googlegroups.com
The Groovy Postbuild plugin exposes some predefined variables like.
  • hudson - the current Hudson instance (javadoc).

I have checked the Javadoc and it looks like much of hudson instance is deprecated.

getInstance()
Deprecated. 
Here only for compatibility. Use Jenkins.getInstance() instead.

Perhaps this plugin should be updated to expose instead:
  • jenkins - the current Jenkins instance (javadoc).

In the mean time till this is updated/fixed in the plugin how do I get the jenkins instance myself?

Daniel Beck

unread,
Mar 4, 2015, 8:03:51 AM3/4/15
to jenkins...@googlegroups.com
It's the same instance.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/1477128d-edec-4860-9a11-473ae942aaf8%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Sverre Moe

unread,
Mar 4, 2015, 8:12:53 AM3/4/15
to jenkins...@googlegroups.com, m...@beckweb.net
Its a little confusing reading the API. What to use between jenkins.model or hudson.model

The link points to hudson.model.Hudson, not jenkins.model.Jenkins
Though I do see that Hudson extends Jenkins.

Daniel Beck

unread,
Mar 4, 2015, 10:55:14 AM3/4/15
to jenkins...@googlegroups.com
On 04.03.2015, at 14:12, Sverre Moe <sverr...@gmail.com> wrote:

> Its a little confusing reading the API. What to use between jenkins.model or hudson.model

Jenkins used to be called Hudson until early 2011. Renaming packages breaks plugins relying on old names, so in general, any class predating 2011 will be in hudson.*, while everything newer is generally in jenkins.*.

> The link points to hudson.model.Hudson, not jenkins.model.Jenkins
> http://javadoc.jenkins-ci.org/?hudson/model/Hudson.html
> Though I do see that Hudson extends Jenkins.

Script:
Hudson.instance == Jenkins.instance

Result: true

So it really doesn't make a difference. Like the package name 'hudson.model', Groovy Postscript predates the rename/fork to Jenkins and therefore uses the older name.

Reply all
Reply to author
Forward
0 new messages