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.

Error when Recommend multiple and Unrecommend multiple build #4665

duclong.ng ·

I find there is a difference between multiple recommend and just one recommend (similar to unrecommend).
Using the save function before or after the BuildListener may result in a difference in the final Status.

multiple recommend

Quickbuild.getInstance(BuildManager.class).save(build);
for (BuildListener listener: PluginManager.instance.getExtensions(BuildListener.class))
	listener.buildRecommended();

just one recommend

for (BuildListener listener: PluginManager.instance.getExtensions(BuildListener.class))
	listener.buildRecommended();
Quickbuild.getInstance(BuildManager.class).save(build);

Please correct logic and synchronized in all function

Track: https://track.pmease.com/browse/QB-4205

  • replies 5
  • views 96
  • stars 1
robinshen ADMIN ·

Thanks for reporting. Will be fixed in next patch release.

duclong.ng ·

Hello@robinshen,
I checked at the new version, the unrecommend function is still not in sync logically.
I also tested different logics on my PC and found that saving before running the listener gives better result.

plugin

try {
	// do something
} catch(Throwable t) {
	build.setStatus(SUCCESSFUL)
}

recommend function

BuildManager.instance.save(build);
for (BuildListener listener: PluginManager.instance.getExtensions(BuildListener.class))
	listener.buildRecommended();

The end result I want is for the recommendation to fail and the status to return to SUCCESSFUL.

robinshen ADMIN ·
duclong.ng ·

Looks like you didn't read my request.
"I also tested different logics on my PC and found that saving before running the listener gives better result."

The last task run should be the undo task in the listener's catch block.

robinshen ADMIN ·

I read your point, but that is not a good practice (change status and revert it back upon failure). The most straightforward and safe approach is to save the build only after all listener code finished without errors.