Skip to content
This repository has been archived by the owner on Dec 15, 2021. It is now read-only.

[JENKINS-28756] GenericSCMStep.getApplicableDescriptors buglet #139

Merged
merged 1 commit into from Jun 9, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion CHANGES.md
Expand Up @@ -4,10 +4,12 @@ Only noting significant user-visible or major API changes, not internal code cle

## 1.9 (upcoming)

* [JENKINS-28756](https://issues.jenkins-ci.org/browse/JENKINS-28756): dropdown for _General SCM_ step incorrectly listed SCMs not compatible with Workflow.

## 1.8 (Jun 01 2015)

* Now based on Jenkins core 1.609.x.
* [JENKINS-24673](https://issues.jenkins-ci.org/browse/JENKINS-24673) [JENKINS-27392](https://issues.jenkins-ci.org/browse/JENKINS-27392) Added `wrap` step, permitting compatibility with plugins offering build wrappers.
* [JENKINS-24673](https://issues.jenkins-ci.org/browse/JENKINS-24673), [JENKINS-27392](https://issues.jenkins-ci.org/browse/JENKINS-27392): Added `wrap` step, permitting compatibility with plugins offering build wrappers.
* [JENKINS-25938](https://issues.jenkins-ci.org/browse/JENKINS-25938): avoid creating a Java (native) thread for every executor (flow build or `node {}` block).
* [JENKINS-22941](https://issues.jenkins-ci.org/browse/JENKINS-22941): allow Jenkins safe restart to proceed even while a flow build is running, so long as it is just waiting (for an external process, `waitUntil`, etc.).
* [JENKINS-26900](https://issues.jenkins-ci.org/browse/JENKINS-26900): hide the “flyweight” executor on master corresponding to the flow build when it is just waiting.
Expand Down
Expand Up @@ -28,10 +28,8 @@
import hudson.model.Job;
import hudson.scm.SCM;
import hudson.scm.SCMDescriptor;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import javax.annotation.CheckForNull;
import org.jenkinsci.plugins.workflow.util.StaplerReferer;
import org.kohsuke.stapler.DataBoundConstructor;

/**
Expand Down Expand Up @@ -63,15 +61,8 @@ public SCM getScm() {
return "General SCM";
}

public Collection<? extends SCMDescriptor<?>> getApplicableDescriptors(@CheckForNull Job<?,?> job) {
// TODO could probably be simplified to SCM._for
List<SCMDescriptor<?>> r = new ArrayList<SCMDescriptor<?>>();
for (SCMDescriptor<?> d : SCM.all()) {
if (job == null || d.isApplicable(job)) {
r.add(d);
}
}
return r;
public Collection<? extends SCMDescriptor<?>> getApplicableDescriptors() {
return SCM._for(StaplerReferer.findItemFromRequest(Job.class));
}

}
Expand Down
Expand Up @@ -25,6 +25,6 @@ THE SOFTWARE.

<?jelly escape-by-default='true'?>
<j:jelly xmlns:j="jelly:core" xmlns:st="jelly:stapler" xmlns:f="/lib/form">
<f:dropdownDescriptorSelector field="scm" title="SCM" descriptors="${descriptor.getApplicableDescriptors(it)}"/>
<f:dropdownDescriptorSelector field="scm" title="SCM" descriptors="${descriptor.applicableDescriptors}"/>
<st:include page="config-generic.jelly" class="org.jenkinsci.plugins.workflow.steps.scm.SCMStep"/>
</j:jelly>
Expand Up @@ -22,7 +22,7 @@
* THE SOFTWARE.
*/

package org.jenkinsci.plugins.workflow.support.steps.build;
package org.jenkinsci.plugins.workflow.util;

import hudson.model.Item;
import java.net.URI;
Expand All @@ -38,8 +38,9 @@

/**
* JENKINS-19413 workaround.
* Will be deleted in the future.
*/
class StaplerReferer {
public class StaplerReferer {
Copy link
Member

Choose a reason for hiding this comment

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

@Restricted or @Deprecated would be useful if you're going to delete it at some point

Copy link
Member Author

Choose a reason for hiding this comment

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

Cannot be @Restricted because I need to use it from sister plugins, unfortunately.


private static final Logger LOGGER = Logger.getLogger(StaplerReferer.class.getName());

Expand Down
Expand Up @@ -17,6 +17,7 @@
import org.jenkinsci.plugins.workflow.steps.AbstractStepDescriptorImpl;
import org.jenkinsci.plugins.workflow.steps.AbstractStepImpl;
import org.jenkinsci.plugins.workflow.steps.Step;
import org.jenkinsci.plugins.workflow.util.StaplerReferer;
import org.kohsuke.accmod.Restricted;
import org.kohsuke.accmod.restrictions.DoNotUse;
import org.kohsuke.stapler.AncestorInPath;
Expand Down