Skip to content

Commit

Permalink
[FIX JENKINS-47905] Provide a default constructor for TriggeredBuildS…
Browse files Browse the repository at this point in the history
…elector
  • Loading branch information
ikedam committed Dec 3, 2017
1 parent 8ba16c0 commit 45b04bc
Showing 1 changed file with 49 additions and 3 deletions.
Expand Up @@ -44,6 +44,7 @@
import org.jenkinsci.Symbol;
import org.jvnet.localizer.Localizable;
import org.kohsuke.stapler.DataBoundConstructor;
import org.kohsuke.stapler.DataBoundSetter;
import org.kohsuke.stapler.StaplerRequest;

/**
Expand Down Expand Up @@ -95,21 +96,41 @@ public boolean isForGlobalSetting() {
}
};
private Boolean fallbackToLastSuccessful;
private final UpstreamFilterStrategy upstreamFilterStrategy;
private UpstreamFilterStrategy upstreamFilterStrategy;
private boolean allowUpstreamDependencies;

@DataBoundConstructor
public TriggeredBuildSelector() {
this(false);
}

/**
* @param fallbackToLastSuccessful {@code true} to fallback to the last successful build when no appropriate build is found.
* @param upstreamFilterStrategy strategy to pick the most appropriate upstream build.
* @param allowUpstreamDependencies {@code true} to scan upstream builds also using relation provided by fingerprints.
* @deprecated Use {@link #TriggeredBuildSelector()} instead.
*/
@Deprecated
public TriggeredBuildSelector(boolean fallbackToLastSuccessful, UpstreamFilterStrategy upstreamFilterStrategy, boolean allowUpstreamDependencies) {
this.fallbackToLastSuccessful = fallbackToLastSuccessful ? Boolean.TRUE : null;
this.upstreamFilterStrategy = upstreamFilterStrategy;
this.setFallbackToLastSuccessful(fallbackToLastSuccessful);
this.setUpstreamFilterStrategy(upstreamFilterStrategy);
this.allowUpstreamDependencies = allowUpstreamDependencies;
}

/**
* @param fallbackToLastSuccessful {@code true} to fallback to the last successful build when no appropriate build is found.
* @param upstreamFilterStrategy strategy to pick the most appropriate upstream build.
* @deprecated Use {@link #TriggeredBuildSelector()} instead.
*/
@Deprecated
public TriggeredBuildSelector(boolean fallbackToLastSuccessful, UpstreamFilterStrategy upstreamFilterStrategy) {
this(fallbackToLastSuccessful, upstreamFilterStrategy, false);
}

/**
* @param fallback {@code true} to fallback to the last successful build when no appropriate build is found.
* @deprecated Use {@link #TriggeredBuildSelector()} instead.
*/
@Deprecated
public TriggeredBuildSelector(boolean fallback) {
this(fallback, UpstreamFilterStrategy.UseGlobalSetting, false);
Expand All @@ -119,13 +140,29 @@ public boolean isFallbackToLastSuccessful() {
return fallbackToLastSuccessful != null && fallbackToLastSuccessful.booleanValue();
}

/**
* @param fallbackToLastSuccessful {@code true} to fallback to the last successful build when no appropriate build is found.
*/
@DataBoundSetter
public void setFallbackToLastSuccessful(boolean fallbackToLastSuccessful) {
this.fallbackToLastSuccessful = fallbackToLastSuccessful ? Boolean.TRUE : null;
}

/**
* @return Which build should be used if triggered by multiple upstream builds.
*/
public UpstreamFilterStrategy getUpstreamFilterStrategy() {
return upstreamFilterStrategy;
}

/**
* @param upstreamFilterStrategy strategy to pick the most appropriate upstream build.
*/
@DataBoundSetter
public void setUpstreamFilterStrategy(UpstreamFilterStrategy upstreamFilterStrategy) {
this.upstreamFilterStrategy = upstreamFilterStrategy;
}

/**
* @return whether to use the newest upstream or not (use the oldest) when there are multiple upstreams.
*/
Expand All @@ -152,6 +189,15 @@ public boolean isAllowUpstreamDependencies() {
return allowUpstreamDependencies;
}


/**
* @param allowUpstreamDependencies {@code true} to scan upstream builds also using relation provided by fingerprints.
*/
@DataBoundSetter
public void setAllowUpstreamDependencies(boolean allowUpstreamDependencies) {
this.allowUpstreamDependencies = allowUpstreamDependencies;
}

@Override
public Run<?,?> getBuild(Job<?,?> job, EnvVars env, BuildFilter filter, Run<?,?> parent) {
Run<?,?> result = null;
Expand Down

0 comments on commit 45b04bc

Please sign in to comment.