Skip to content

Commit

Permalink
Make the default value for percentage appear in config forms.
Browse files Browse the repository at this point in the history
This makes it consistent with how the files pattern works, i.e. its
default value appears in the job config form, and the Pipeline snippet
generator.

Also made percentage values appear with the %-sign suffix, as it looks
a little bit nicer, and helps further reinfoce that it's a percentage
value and not a fraction, i.e. should be set to '50%' rather than '0.5'.
  • Loading branch information
orrc committed May 22, 2020
1 parent 22fac28 commit 6d111db
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 12 deletions.
Expand Up @@ -134,15 +134,19 @@ public void setRolloutPercentage(@Nonnull String percentage) {
this.rolloutPercentage = percentage;
return;
}
this.rolloutPercentage = pct.intValue() == DescriptorImpl.defaultRolloutPercent ? null : pctStr;
this.rolloutPercentage = pct.intValue() == DescriptorImpl.defaultRolloutPercentage ? null : pctStr;
}

@Nonnull
public String getRolloutPercentage() {
if (fixEmptyAndTrim(rolloutPercentage) == null) {
return String.valueOf(DescriptorImpl.defaultRolloutPercent);
String pct = fixEmptyAndTrim(rolloutPercentage);
if (pct == null) {
pct = String.valueOf(DescriptorImpl.defaultRolloutPercentage);
}
return rolloutPercentage;
if (!pct.endsWith("%") && !pct.matches(REGEX_VARIABLE)) {
pct += "%";
}
return pct;
}

// Required for Pipeline builds using the deprecated `rolloutPercent` option
Expand Down Expand Up @@ -610,7 +614,7 @@ public FormValidation doCheckText(@QueryParameter String value) {
@Extension
public static final class DescriptorImpl extends GooglePlayBuildStepDescriptor<Publisher> {
public static final String defaultFilesPattern = "**/build/outputs/**/*.aab, **/build/outputs/**/*.apk";
public static final int defaultRolloutPercent = 100;
public static final int defaultRolloutPercentage = 100;

public String getDisplayName() {
return "Upload Android AAB/APKs to Google Play";
Expand Down
Expand Up @@ -144,15 +144,19 @@ public void setRolloutPercentage(@Nonnull String percentage) {
this.rolloutPercentage = percentage;
return;
}
this.rolloutPercentage = pct.intValue() == DescriptorImpl.defaultRolloutPercent ? null : pctStr;
this.rolloutPercentage = pct.intValue() == DescriptorImpl.defaultRolloutPercentage ? null : pctStr;
}

@Nonnull
public String getRolloutPercentage() {
if (fixEmptyAndTrim(rolloutPercentage) == null) {
return String.valueOf(DescriptorImpl.defaultRolloutPercent);
String pct = fixEmptyAndTrim(rolloutPercentage);
if (pct == null) {
pct = String.valueOf(ApkPublisher.DescriptorImpl.defaultRolloutPercentage);
}
return rolloutPercentage;
if (!pct.endsWith("%") && !pct.matches(REGEX_VARIABLE)) {
pct += "%";
}
return pct;
}

// Required for Pipeline builds using the deprecated `rolloutPercent` option
Expand Down Expand Up @@ -369,7 +373,7 @@ private static final class AppInfo {
@Extension
public static final class DescriptorImpl extends GooglePlayBuildStepDescriptor<Builder> {
public static final String defaultFilesPattern = "**/build/outputs/**/*.aab, **/build/outputs/**/*.apk";
public static final int defaultRolloutPercent = 100;
public static final int defaultRolloutPercentage = 100;

public String getDisplayName() {
return "Move Android apps to a different release track";
Expand Down
Expand Up @@ -27,7 +27,7 @@

<f:entry title="${%Rollout %}" field="rolloutPercentage"
description="${%Defaults to 100% if not set}">
<f:combobox style="width:15em" default="${descriptor.defaultRolloutPercent}" />
<f:textbox style="width:15em" default="${descriptor.defaultRolloutPercentage}%" />
</f:entry>

<f:entry title="${%Recent changes}" field="recentChangeList">
Expand Down
Expand Up @@ -35,7 +35,7 @@

<f:entry title="${%Rollout %}" field="rolloutPercentage"
description="${%Defaults to 100% if not set}">
<f:combobox style="width:15em" default="${descriptor.defaultRolloutPercent}" />
<f:textbox style="width:15em" default="${descriptor.defaultRolloutPercentage}%" />
</f:entry>

</j:jelly>

0 comments on commit 6d111db

Please sign in to comment.