violations-plugin: IllegalStateException: cannot change build result while in COMPLETED

328 views
Skip to first unread message

Mirko Friedenhagen

unread,
Dec 16, 2014, 4:54:09 PM12/16/14
to jenkin...@googlegroups.com
Hello everybody,

In 28dfd90d2d6ae99c57eb174871c46f4e07e303ba a change in jerkins-core
was introduced which results in a IllegalStateException when a plugin
tries to to change the build result when the build is already
completed.

I see why this might have been done, however right now this breaks the
violations-plugin[1]. I am trying to fix this as a lot of jobs here
rely on this plugin and developers are used to it[2].

The ViolationsReporter overrides hudson.maven.MavenReporter#end and
tries to set the result here which leads to the exception in [1] since
above commit.

The end method references hudson.maven.MavenReporter#postBuild however
this method is called after a single Maven module finished but not
after all builds in a reactor finished.

Is there a good way to get hook after the last module finished except
of holding state myself?

And what is the difference between postBuild and leaveModule?

Almost any hints are appreciated[2].

Regards Mirko
[1] https://groups.google.com/d/msg/jenkinsci-users/jrkAQyq6jLs/unCEaa5CFcMJ
[2] The analyze plugin suite gives the information much more dispersed
and jeep, I know the Maven project type is evil ;-))
--
http://illegalstateexception.blogspot.com/
https://github.com/mfriedenhagen/ (http://osrc.dfm.io/mfriedenhagen)
https://bitbucket.org/mfriedenhagen/

Jesse Glick

unread,
Dec 16, 2014, 5:59:05 PM12/16/14
to Jenkins Dev
On Tue, Dec 16, 2014 at 4:53 PM, Mirko Friedenhagen
<mfried...@gmail.com> wrote:
> The ViolationsReporter overrides hudson.maven.MavenReporter#end and
> tries to set the result here which leads to the exception in [1] since
> above commit.

Looks similar to, but not identical to,

https://issues.jenkins-ci.org/browse/JENKINS-25406

See my suggestion there about setting MavenBuild.result directly.

Ulli Hafner

unread,
Dec 17, 2014, 9:12:22 AM12/17/14
to jenkin...@googlegroups.com
Maybe you can have a look at a maven reporter of one of the static analysis plug-ins (findbugs, checkstyle, …). The code to publish the results should be quite similar...
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr1dy2ERZ94coQyj98S%2BCtuhmnCsn%2BwT_qbm9--jm140yQ%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.

signature.asc

Jesse Glick

unread,
Dec 17, 2014, 9:55:45 AM12/17/14
to Jenkins Dev
On Wed, Dec 17, 2014 at 9:12 AM, Ulli Hafner <ullrich...@gmail.com> wrote:
> maven reporter of one of the static analysis plug-ins (findbugs, checkstyle, …). The code to publish the results should be quite similar...

…and broken for the same reason, as JENKINS-25406 notes.

Mirko Friedenhagen

unread,
Dec 17, 2014, 12:47:10 PM12/17/14
to jenkin...@googlegroups.com
Jesse,

this is indeed similar to JENKINS-25406. Do I understand your comment right:
- I should change the visibility of the result field of MavenBuild to
set it from the outside?
- Feels like a hack to me :-).
Regards Mirko

Jesse Glick

unread,
Dec 17, 2014, 2:06:50 PM12/17/14
to Jenkins Dev
On Wed, Dec 17, 2014 at 12:46 PM, Mirko Friedenhagen
<mfried...@gmail.com> wrote:
> I should change the visibility of the result field of MavenBuild to set it from the outside?

Well, introduce a method in MavenBuild intended to set the result at
an appropriate time, despite the state being technically completed, as
opposed to setResult which has always had the semantics (even if not
previously enforced) of being legal only for a running build.

I do not really understand _why_ the status is getting updated after
the module build is “complete”. That is a question for someone more
intimately familiar with this plugin. I am just presuming that it is
legitimate in this case.

Mirko Friedenhagen

unread,
Dec 17, 2014, 3:20:24 PM12/17/14
to jenkin...@googlegroups.com

Jesse Glick

unread,
Dec 17, 2014, 3:39:31 PM12/17/14
to Jenkins Dev
On Wed, Dec 17, 2014 at 3:19 PM, Mirko Friedenhagen
<mfried...@gmail.com> wrote:
> Is that the solution you had in mind?

No, this should be addressed in maven-plugin.

Mirko Friedenhagen

unread,
Dec 17, 2014, 4:38:57 PM12/17/14
to jenkin...@googlegroups.com
I now tried a different approach by setting the result in a overridden
postBuild method. However this one is never called.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Developers" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-de...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-dev/CANfRfr3tPNOP_r%2BUv%3De63%2B8zD7xjyZ-0PgVc1xHwa1s6kXogsQ%40mail.gmail.com.

Mirko Friedenhagen

unread,
Dec 22, 2014, 4:03:54 PM12/22/14
to jenkin...@googlegroups.com
Jesse,

the other approach of setting the result in postBuild did not really
work unfortunately. I am not sure I understand how and why events are
called in Jenkins here.
- Say I have a Maven multi-module project *and* have created a
Jenkins-Maven-Job.
- From the Javadoc of hudson.maven.MavenReporter:

* <pre>
* SEQUENCE := preBuild MODULE* postBuild end
* MODULE := enterModule MOJO+ leaveModule
* MOJO := preExecute postExecute
* </pre>

What I do not understand:
- Should preBuild. postBuild and end not only be called once per Maven
execution? I see a lot of postBuild invocations (more than one per
module)
- For every module in my multi-module build I would expect one
invocation per module?
On Wed, Dec 17, 2014 at 10:38 PM, Mirko Friedenhagen

Jesse Glick

unread,
Dec 22, 2014, 4:41:23 PM12/22/14
to Jenkins Dev
On Mon, Dec 22, 2014 at 4:03 PM, Mirko Friedenhagen
<mfried...@gmail.com> wrote:
> I am not sure I understand how and why events are called in Jenkins here.

You are going to have to ask someone familiar with the mojo hook
system in this plugin, which I do not know much about.
Reply all
Reply to author
Forward
0 new messages