diff --git a/core/src/main/java/hudson/PluginManager.java b/core/src/main/java/hudson/PluginManager.java index 80d783a079daf870d2220bd4d3d0ca2cd40edc4c..99755339adfe7c2b1fa0dd8137037799251a998c 100644 --- a/core/src/main/java/hudson/PluginManager.java +++ b/core/src/main/java/hudson/PluginManager.java @@ -706,6 +706,7 @@ public abstract class PluginManager extends AbstractModelObject { throw new Failure(hudson.model.Messages.Hudson_NotAPlugin(fileName)); } final String baseName = FilenameUtils.getBaseName(fileName); + new File(rootDir, baseName + ".hpi").delete(); // don't keep confusing legacy *.hpi fileItem.write(new File(rootDir, baseName + ".jpi")); // rename all new plugins to *.jpi fileItem.delete(); diff --git a/core/src/main/java/hudson/model/AbstractBuild.java b/core/src/main/java/hudson/model/AbstractBuild.java index afbdd0284677514210621567274d84d0b544d1b7..fc12d0c25d16e436dee76c69e07b3f3493479885 100644 --- a/core/src/main/java/hudson/model/AbstractBuild.java +++ b/core/src/main/java/hudson/model/AbstractBuild.java @@ -439,6 +439,14 @@ public abstract class AbstractBuild

,R extends Abs return Executor.currentExecutor().getOwner().getNode(); } + public Launcher getLauncher() { + return launcher; + } + + public BuildListener getListener() { + return listener; + } + /** * Allocates the workspace from {@link WorkspaceList}. * @@ -482,8 +490,8 @@ public abstract class AbstractBuild

,R extends Abs wl.beforeUse(AbstractBuild.this, lease.path, listener); } - getProject().getSCMCheckoutStrategy().preCheckout(AbstractBuild.this, launcher, this.listener); - getProject().getSCMCheckoutStrategy().checkout(this); + getProject().getScmCheckoutStrategy().preCheckout(AbstractBuild.this, launcher, this.listener); + getProject().getScmCheckoutStrategy().checkout(this); if (!preBuild(listener,project.getProperties())) return Result.FAILURE; diff --git a/core/src/main/java/hudson/model/AbstractProject.java b/core/src/main/java/hudson/model/AbstractProject.java index 64247047ab637f9a75a50c550204df952845a92f..d2447434428450a4e42967d3fe495d13eb622174 100644 --- a/core/src/main/java/hudson/model/AbstractProject.java +++ b/core/src/main/java/hudson/model/AbstractProject.java @@ -531,11 +531,11 @@ public abstract class AbstractProject

,R extends A return quietPeriod!=null ? quietPeriod : Jenkins.getInstance().getQuietPeriod(); } - public SCMCheckoutStrategy getSCMCheckoutStrategy() { + public SCMCheckoutStrategy getScmCheckoutStrategy() { return scmCheckoutStrategy == null ? new DefaultSCMCheckoutStrategyImpl() : scmCheckoutStrategy; } - public void setSCMCheckoutStrategy(SCMCheckoutStrategy scmCheckoutStrategy) throws IOException { + public void setScmCheckoutStrategy(SCMCheckoutStrategy scmCheckoutStrategy) throws IOException { this.scmCheckoutStrategy = scmCheckoutStrategy; save(); } @@ -1988,9 +1988,8 @@ public abstract class AbstractProject

,R extends A return c; } - public List getApplicableSCMCheckoutStrategyDescriptors(@AncestorInPath AbstractProject p) { + public List getApplicableSCMCheckoutStrategyDescriptors(AbstractProject p) { return SCMCheckoutStrategyDescriptor._for(p); - } /** diff --git a/core/src/main/resources/lib/hudson/project/config-scm.jelly b/core/src/main/resources/lib/hudson/project/config-scm.jelly index d47a4f0ccda5d253500973e2353da767bfbc4281..6874bb2dfb9105526635d239d5b43bdb0214b177 100644 --- a/core/src/main/resources/lib/hudson/project/config-scm.jelly +++ b/core/src/main/resources/lib/hudson/project/config-scm.jelly @@ -38,7 +38,7 @@ THE SOFTWARE. - + pom.xml relative to the workspace root. + * @since 1.466 */ public String getRootPOM(EnvVars env) { if (rootPOM == null) return "pom.xml"; diff --git a/test/src/main/java/jenkins/scm/SCMCheckoutStrategyTest.java b/test/src/main/java/jenkins/scm/SCMCheckoutStrategyTest.java new file mode 100644 index 0000000000000000000000000000000000000000..cbdd097de591707da25db59d302bf103bbaa8915 --- /dev/null +++ b/test/src/main/java/jenkins/scm/SCMCheckoutStrategyTest.java @@ -0,0 +1,73 @@ +package jenkins.scm; + +import com.gargoylesoftware.htmlunit.html.HtmlPage; +import hudson.model.FreeStyleProject; +import org.jvnet.hudson.test.HudsonTestCase; +import org.jvnet.hudson.test.TestExtension; +import hudson.model.AbstractProject; +import org.kohsuke.stapler.DataBoundConstructor; +import hudson.model.AbstractBuild.AbstractBuildExecution; +import org.xml.sax.SAXException; + +import java.io.IOException; + +/** + * + * + * @author Kohsuke Kawaguchi + */ +public class SCMCheckoutStrategyTest extends HudsonTestCase { + public void testConfigRoundtrip() throws Exception { + assertEquals(1,SCMCheckoutStrategyDescriptor.all().size()); + FreeStyleProject p = createFreeStyleProject(); + assertFalse(pageHasUI(p)); // no configuration UI because there's only one option + } + + /** + * This should show the UI. + */ + public void testConfigRoundtrip2() throws Exception { + assertEquals(2,SCMCheckoutStrategyDescriptor.all().size()); + FreeStyleProject p = createFreeStyleProject(); + System.out.println(SCMCheckoutStrategyDescriptor.all()); + + TestSCMCheckoutStrategy before = new TestSCMCheckoutStrategy(); + p.setScmCheckoutStrategy(before); + configRoundtrip(p); + SCMCheckoutStrategy after = p.getScmCheckoutStrategy(); + assertNotSame(before,after); + assertSame(before.getClass(), after.getClass()); + + assertTrue(pageHasUI(p)); + } + + private boolean pageHasUI(FreeStyleProject p) throws IOException, SAXException { + HtmlPage page = createWebClient().getPage(p, "configure"); + return page.getWebResponse().getContentAsString().contains("Advanced Source Code Management"); + } + + public static class TestSCMCheckoutStrategy extends SCMCheckoutStrategy { + @DataBoundConstructor + public TestSCMCheckoutStrategy() { + } + + @Override + public void checkout(AbstractBuildExecution execution) throws IOException, InterruptedException { + execution.getListener().getLogger().println("Hello!"); + super.checkout(execution); + } + + @TestExtension("testConfigRoundtrip2") + public static class DescriptorImpl extends SCMCheckoutStrategyDescriptor { + @Override + public boolean isApplicable(AbstractProject project) { + return true; + } + + @Override + public String getDisplayName() { + return getClass().getName(); + } + } + } +}