提交 a68d6447 编写于 作者: K Kohsuke Kawaguchi

Merge commit 'ddd68671'

......@@ -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();
......
......@@ -439,6 +439,14 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,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<P extends AbstractProject<P,R>,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;
......
......@@ -531,11 +531,11 @@ public abstract class AbstractProject<P extends AbstractProject<P,R>,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<P extends AbstractProject<P,R>,R extends A
return c;
}
public List<SCMCheckoutStrategyDescriptor> getApplicableSCMCheckoutStrategyDescriptors(@AncestorInPath AbstractProject p) {
public List<SCMCheckoutStrategyDescriptor> getApplicableSCMCheckoutStrategyDescriptors(AbstractProject p) {
return SCMCheckoutStrategyDescriptor._for(p);
}
/**
......
......@@ -38,7 +38,7 @@ THE SOFTWARE.
</j:forEach>
</f:section>
<j:set var="descriptors" value="${descriptor.getApplicableSCMCheckoutStrategyDescriptors()}"/>
<j:set var="descriptors" value="${descriptor.getApplicableSCMCheckoutStrategyDescriptors(instance)}"/>
<j:if test="${descriptors.size() gt 1}">
<f:section title="${%Advanced Source Code Management}">
<f:dropdownDescriptorSelector title="${%SCM Checkout Strategy}" field="scmCheckoutStrategy"
......
......@@ -807,8 +807,18 @@ public class MavenModuleSet extends AbstractMavenProject<MavenModuleSet,MavenMod
return activities;
}
/**
*
* @deprecated for backward comp only
* @return
*/
public String getRootPOM(){
return getRootPOM( null );
}
/**
* Gets the location of top-level <tt>pom.xml</tt> relative to the workspace root.
* @since 1.466
*/
public String getRootPOM(EnvVars env) {
if (rootPOM == null) return "pom.xml";
......
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();
}
}
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册