Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix 'instance' being null when creating a new item.
  • Loading branch information
glenritchie committed Apr 9, 2015
1 parent 9a6a9f7 commit 2ce0bde
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 20 deletions.
14 changes: 1 addition & 13 deletions src/main/java/hudson/plugins/release/ReleaseWrapper.java
Expand Up @@ -169,19 +169,7 @@ public Run<?,?> resolve(Job<?,?> job) {
*/
public ReleaseWrapper() {
}

public List<Descriptor> getBuildSteps(AbstractProject<?,?> project)
{
List<Descriptor<Publisher>> publishers = Functions.getPublisherDescriptors(project);
List<Descriptor<Builder>> builders = Functions.getBuilderDescriptors(project);

List<Descriptor> descriptors = new LinkedList<Descriptor>();
descriptors.addAll(publishers);
descriptors.addAll(builders);

return descriptors;
}


public String getReleaseVersionTemplate() {
return releaseVersionTemplate;
}
Expand Down
35 changes: 35 additions & 0 deletions src/main/java/hudson/plugins/release/ReleaseWrapperHelper.java
@@ -0,0 +1,35 @@
/*
*
*/
package hudson.plugins.release;

import hudson.Functions;
import hudson.model.AbstractProject;
import hudson.model.Descriptor;
import hudson.tasks.Builder;
import hudson.tasks.Publisher;
import java.util.LinkedList;
import java.util.List;

/**
* Helper class
*/
public class ReleaseWrapperHelper
{
/** Retrieve a list of all build steps including publishers and builders
*
* @param project The project
* @return A list of descriptor's for both publishers and builders
*/
static public List<Descriptor> getBuildSteps(AbstractProject<?,?> project)
{
List<Descriptor<Publisher>> publishers = Functions.getPublisherDescriptors(project);
List<Descriptor<Builder>> builders = Functions.getBuilderDescriptors(project);

List<Descriptor> descriptors = new LinkedList<Descriptor>();
descriptors.addAll(publishers);
descriptors.addAll(builders);

return descriptors;
}
}
Expand Up @@ -27,6 +27,13 @@
xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"
xmlns:p="/lib/hudson/project">

<!-- Due to bug JENKINS-26579 we can't just call j:new, we have to use this workaround to get an instance of the helper class
that we can then use to call the static method getBuildSteps()
-->
<j:set var="h2" value="${app.pluginManager.uberClassLoader.loadClass('hudson.plugins.release.ReleaseWrapperHelper').newInstance()}"/>

<!-- ${app.pluginManager.uberClassLoader.loadClass('pkg.SomeExtension').getMethod('all', null).invoke(null, null)} -->

<f:entry title="${%Release Version Template}" help="/plugin/release/help-releaseVersionTemplate.html">
<f:textbox field="releaseVersionTemplate" />
</f:entry>
Expand Down Expand Up @@ -58,7 +65,7 @@
<!-- Pre build steps -->
<label class="attach-previous">${%Before release build}</label>
<f:hetero-list name="preBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.preBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -72,7 +79,7 @@
<!-- Post successful build steps -->
<label class="attach-previous">${%After successful release build}</label>
<f:hetero-list name="postSuccessfulBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.postSuccessfulBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -86,7 +93,7 @@
<!-- Post failed build steps -->
<label class="attach-previous">${%After failed release build}</label>
<f:hetero-list name="postFailedBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.postFailedBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -100,7 +107,7 @@
<!-- Post build steps -->
<label class="attach-previous">${%After failed or successful release build}</label>
<f:hetero-list name="postBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.postBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -115,7 +122,7 @@
<!-- Pre matrix build steps -->
<label class="attach-previous">${%Before release build and all matrix configurations}</label>
<f:hetero-list name="preMatrixBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.preMatrixBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -141,7 +148,7 @@
<!-- Post failed build steps -->
<label class="attach-previous">${%After failed release build and all matrix configurations}</label>
<f:hetero-list name="postFailedMatrixBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.postFailedMatrixBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand All @@ -155,7 +162,7 @@
<!-- Post build steps -->
<label class="attach-previous">${%After failed or successful release build and all matrix configurations}</label>
<f:hetero-list name="postBuildSteps" hasHeader="true"
descriptors="${instance.getBuildSteps(it)}"
descriptors="${h2.getBuildSteps(it)}"
items="${instance.postBuildSteps}"
addCaption="${%Add release step}"/>
</div>
Expand Down

0 comments on commit 2ce0bde

Please sign in to comment.