Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JENKINS-49488] implement any_met_condition flag for PromotionProcess.isMet() #115

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

totoroliu
Copy link

JENKINS-49488: implement any_met_condition flag for PromotionProcess.isMet()

When any_met_condition flag is true,
any met promotion condition would qualify for promote.

@totoroliu totoroliu changed the title JENKINS-49488: JENKINS-49488: implement any_met_condition flag for PromotionProcess.isMet() JENKINS-49488: implement any_met_condition flag for PromotionProcess.isMet() Mar 24, 2018
@totoroliu totoroliu changed the title JENKINS-49488: implement any_met_condition flag for PromotionProcess.isMet() [JENKINS-49488]: implement any_met_condition flag for PromotionProcess.isMet() Mar 24, 2018
@totoroliu totoroliu changed the title [JENKINS-49488]: implement any_met_condition flag for PromotionProcess.isMet() [JENKINS-49488] implement any_met_condition flag for PromotionProcess.isMet() Mar 24, 2018
…isMet()

When any_met_condition flag is true,
any met promotion condition would qualify for promote.
@totoroliu
Copy link
Author

any updates on this PR?

@totoroliu
Copy link
Author

@dwnusbaum
Could you also help review this pull request?
Thanks~

Copy link
Member

@oleg-nenashev oleg-nenashev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would rather prefer an "OR" condition which groups other conditions, but it should do the job. minor changes are needed imho

if(b==null)
return null;
badges.add(b);
LOGGER.log(Level.INFO, "PromotionProcess.isMet(): any_met_condition={0}", this.any_met_condition);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logging does not help - PromotionProcess is not references in the entry

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i'll remove this line

/**
* Trigger promotion when any criteria condition is met.
*/
public boolean any_met_condition;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would advice against introducing any more public fields in the plugin

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can I use protected or private here?
I recall I hit an issue before when not using public.

@totoroliu
Copy link
Author

yes, at beginning I was trying to use "Confitional Plugin"
which provides the flexibility of all possible combination of conditions.
But eventually the change was too big and beyond my capability.

Copy link
Member

@dwnusbaum dwnusbaum left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Things look mostly good now, the main thing that I think is left is to add some automated tests to show that the feature works.

/**
* Trigger promotion when any criteria condition is met.
*/
private boolean any_met_condition;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Java convention is to use camel case like anyMetCondition.

return null;
badges.add(b);
if (this.any_met_condition) {
if (b!=null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Since you're modifying these two if statements anyway, I think it would be good to go ahead and use braces around the conditional statements.

@@ -41,6 +41,11 @@
</select>
</f:entry>

<f:entry title="Any_Met">
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this what shows up in the UI? Maybe something like Promote if ANY of the above conditions are met would be more clear to users, but I'm not sure what would be best.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The GUI looks like this:
Due to the alignment, I can't have long string at the title.
image

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the screenshot! Maybe use Any Met with no underscore?

@totoroliu
Copy link
Author

Do you have an existing test case that's testing multiple conditions with "AND"?

@dwnusbaum
Copy link
Member

@totoroliu I think SelfPromotionTest#testBasic uses 2 self promotion conditions, so maybe you could use that but change one of them into a ManualCondition that you never trigger to show your new option works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants