Your browser was unable to load all of the resources. They may have been blocked by your firewall, proxy or browser configuration.
Press Ctrl+F5 or Ctrl+Shift+R to have your browser try again.

An improvement to BuildListener #4562

duclong.ng ·

BuildListener is already very good with the current functions. But I want to add a few other things.
Current:

...
void buildFinished();
void buildRecommended();
void buildUnRecommended();

Update:

...
void buildFinished();
void buildRecommended();
void buildUnRecommended();
boolean recommendBuild();
boolean unRecommendBuild();

There are several things that need to be done at the same time when a build is recommended and unrecommended. i am using "void buildRecommended();" for that. However, it always returns void and when an error occurs, the build status is still changed to recommended while in fact the related tasks have failed.
@robinshen Can this be applied?

  • replies 5
  • views 674
  • stars 0
robinshen ADMIN ·

You may throw exception when there is something wrong and want to prevent build from being recommended/unrecommented.

duclong.ng ·

Hello@robinshen ,
I threw an exception but it didn't prevent the build from being changed to recommended.
Please check BuildResource.java

build.setStatus(Status.RECOMMENDED);
Context.push(build);
try {
	for (BuildListener listener: PluginManager.instance.getExtensions(BuildListener.class))
		listener.buildRecommended();
} finally {
	Context.pop();
}

Is it possible to add a catch block to revert build status when an exception occurs?

} catch (Exception e) {
	build.setStatus(Status.SUCCESSFUL);
	logger.error(e);
}

How do you think?

robinshen ADMIN ·

Are you recommending via restful api. I just add a plugin contributing a BuildListener extension point throwing exception in buildRecommended method, and the restful api call will not change build status from successful to recommended, which is the expected behavior.

BTW: I am testing with QB14

duclong.ng ·

"the restful api call will not change build status from successful to recommended"
It doesn't work the same with buttons. Can you make the buttons work like this too?

robinshen ADMIN ·

I see. This will be addressed in next patch release.