Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix regression of rebuild of non-parameter build
This corrects the regression involved when builds are triggered
with parameters that have not been defined in the job.

Without this fix, the Rebuild Action does not display the build parameters
that were previously used by the build that is being rebuilt.

This fixes [FIXED JENKINS-24491]
  • Loading branch information
escoheb committed Oct 1, 2014
1 parent e6b2603 commit 62206ea
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 104 deletions.
42 changes: 17 additions & 25 deletions src/main/java/com/sonyericsson/rebuild/RebuildAction.java
Expand Up @@ -27,11 +27,6 @@
import hudson.Extension;
import hudson.model.Action;






import javax.servlet.ServletException;

import java.io.IOException;
Expand Down Expand Up @@ -59,7 +54,6 @@
import org.kohsuke.stapler.Stapler;
import org.kohsuke.stapler.StaplerRequest;
import org.kohsuke.stapler.StaplerResponse;
import org.kohsuke.stapler.WebApp;

import com.sonyericsson.rebuild.RebuildParameterPage;
import com.sonyericsson.rebuild.RebuildParameterProvider;
Expand All @@ -74,9 +68,9 @@ public class RebuildAction implements Action {

private static final String SVN_TAG_PARAM_CLASS = "hudson.scm.listtagsparameter.ListSubversionTagsParameterValue";
/*
* All the below transient variables are declared only for backward
* compatibility of the rebuild plugin.
*/
* All the below transient variables are declared only for backward
* compatibility of the rebuild plugin.
*/
private transient String rebuildurl = "rebuild";
private transient String parameters = "rebuildParam";
private transient String p = "parameter";
Expand Down Expand Up @@ -204,8 +198,7 @@ public String getUrlName() {
* @throws ServletException if something unfortunate happens.
* @throws InterruptedException if something unfortunate happens.
*/
public void doIndex(StaplerRequest request, StaplerResponse response) throws
IOException, ServletException, InterruptedException {
public void doIndex(StaplerRequest request, StaplerResponse response) throws IOException, ServletException, InterruptedException {
AbstractBuild currentBuild = request.findAncestorObject(AbstractBuild.class);
if (currentBuild != null) {
ParametersAction paramAction = currentBuild.getAction(ParametersAction.class);
Expand Down Expand Up @@ -272,8 +265,7 @@ public void nonParameterizedRebuild(AbstractBuild currentBuild, StaplerResponse
* @throws IOException if something unfortunate happens.
* @throws InterruptedException if something unfortunate happens.
*/
public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws
ServletException, IOException, InterruptedException {
public void doConfigSubmit(StaplerRequest req, StaplerResponse rsp) throws ServletException, IOException, InterruptedException {
AbstractProject project = getProject();
if (project == null) {
return;
Expand Down Expand Up @@ -441,7 +433,7 @@ private ParameterValue cloneParameter(ParameterValue oldValue, String newValue)
}
throw new IllegalArgumentException("Unrecognized parameter type: " + oldValue.getClass());
}
/**
/**
* Method for constructing Rebuild cause.
*
* @param up AbsstractBuild
Expand All @@ -456,7 +448,7 @@ private List<Action> constructRebuildCause(AbstractBuild up, ParametersAction pa
}
return actions;
}

/**
* @param value the parameter value to show to rebuild.
* @return page for the parameter value, or null if no suitable option found.
Expand All @@ -470,16 +462,16 @@ public RebuildParameterPage getRebuildParameterPage(ParameterValue value) {
}

// Check if we have a branched Jelly in the plugin.
if (getClass().getResource(String.format("/%s/%s.jelly", getClass().getCanonicalName().replace('.', '/'), value.getClass().getSimpleName())) != null) {
// No provider available, use an existing view provided by rebuild plugin.
return new RebuildParameterPage(
getClass(),
String.format("%s.jelly", value.getClass().getSimpleName())
);
}
// Else we return that we haven't found anything.
// So Jelly fallback could occur.
if (getClass().getResource(String.format("/%s/%s.jelly", getClass().getCanonicalName().replace('.', '/'), value.getClass().getSimpleName())) != null) {
// No provider available, use an existing view provided by rebuild plugin.
return new RebuildParameterPage(
getClass(),
String.format("%s.jelly", value.getClass().getSimpleName())
);

}
// Else we return that we haven't found anything.
// So Jelly fallback could occur.
return null;
}
}
Expand Up @@ -74,7 +74,7 @@ THE SOFTWARE.
<st:include it="${parameterDefinition.copyWithDefaultValue(parameterValue)}"
page="${parameterDefinition.descriptor.valuePage}" />
</j:if>
</j:if>
</j:if>
<j:if test="${parameterValue == null}">
<!-- No previous value in case of new property definition introduced in the config,
so let's use the default from parameter definition -->
Expand All @@ -83,6 +83,14 @@ THE SOFTWARE.
</j:if>
</tbody>
</j:forEach>
<j:if test="${empty(parametersProperty.parameterDefinitions)}">
<j:forEach var="parameterValue" items="${paramAction.parameters}">
<j:scope>
<j:set var="page" value="${it.getRebuildParameterPage(parameterValue)}" />
<st:include it="${parameterValue}" class="${page.clazz}" page="${page.page}" />
</j:scope>
</j:forEach>
</j:if>
<br/>
<br/>
<f:block>
Expand Down

3 comments on commit 62206ea

@ewolk
Copy link

@ewolk ewolk commented on 62206ea Nov 10, 2014

Choose a reason for hiding this comment

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

@shemeersulaiman {or whoever manages the releases} will this be in 1.23? forgive me if this isnt the right place/person to ask

@oleg-nenashev
Copy link
Member

Choose a reason for hiding this comment

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

@ewolk
Yes, this patch has been added to the master branch.
@rsandell any plans on the plugin's release?

@rsandell
Copy link
Member

Choose a reason for hiding this comment

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

I've pinged @shemeersulaiman and @TWestling via mail to see what their plans are. I usually don't want to make a release without the blessing of the official maintainers, I'm only helping out with pull requests every now and then.
But I don't think there are any specific plans to have anything else in the next release.

Please sign in to comment.