-
Notifications
You must be signed in to change notification settings - Fork 168
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
base: master
Are you sure you want to change the base?
Changes from 3 commits
eadb5b2
1811606
b2d61fb
6f31e50
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,7 @@ | |
import java.util.List; | ||
import java.util.Set; | ||
import java.util.concurrent.Future; | ||
import java.util.logging.Level; | ||
import java.util.logging.Logger; | ||
import java.util.regex.Pattern; | ||
import javax.annotation.CheckForNull; | ||
|
@@ -90,6 +91,11 @@ public final class PromotionProcess extends AbstractProject<PromotionProcess,Pro | |
*/ | ||
public String isVisible; | ||
|
||
/** | ||
* Trigger promotion when any criteria condition is met. | ||
*/ | ||
private boolean any_met_condition; | ||
|
||
private List<BuildStep> buildSteps = new ArrayList<BuildStep>(); | ||
|
||
/*package*/ PromotionProcess(JobPropertyImpl property, String name) { | ||
|
@@ -144,6 +150,7 @@ public void doSetName(String name) { | |
assignedLabel = null; | ||
} | ||
isVisible = c.getString("isVisible"); | ||
any_met_condition = c.optBoolean("any_met_condition"); | ||
save(); | ||
} | ||
|
||
|
@@ -213,6 +220,13 @@ public List<BuildStep> getBuildSteps() { | |
return buildSteps; | ||
} | ||
|
||
/** | ||
* JENKINS-49488: Provide public getter for any_met_condition | ||
*/ | ||
public boolean getAnyMetCondition() { | ||
return any_met_condition; | ||
} | ||
|
||
/** | ||
* Gets the textual representation of the assigned label as it was entered by the user. | ||
* @return Assigned label string | ||
|
@@ -372,11 +386,20 @@ public Status isMet(AbstractBuild<?,?> build) { | |
List<PromotionBadge> badges = new ArrayList<PromotionBadge>(); | ||
for (PromotionCondition cond : conditions) { | ||
PromotionBadge b = cond.isMet(this, build); | ||
if(b==null) | ||
return null; | ||
badges.add(b); | ||
if (this.any_met_condition) { | ||
if (b!=null) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
badges.add(b); | ||
} else { | ||
if(b==null) | ||
return null; | ||
badges.add(b); | ||
} | ||
} | ||
if (badges.isEmpty()) { | ||
return null; | ||
} else { | ||
return new Status(this,badges); | ||
} | ||
return new Status(this,badges); | ||
} | ||
|
||
/** | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -41,6 +41,11 @@ | |
</select> | ||
</f:entry> | ||
|
||
<f:entry title="Any_Met"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this what shows up in the UI? Maybe something like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for the screenshot! Maybe use |
||
<f:checkbox name="any_met_condition" title="${%Trigger promotion when any criteria condition is met}" | ||
checked="${instance.getAnyMetCondition()}"/> | ||
</f:entry> | ||
|
||
<f:optionalBlock name="hasAssignedLabel" title="${%Restrict where this promotion process can be run}" | ||
checked="${instance.assignedLabelString!=null}" inline="true"> | ||
<f:entry title="${%Label Expression}" | ||
|
There was a problem hiding this comment.
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
.