提交 af1a4a20 编写于 作者: V Vojtech Juranek 提交者: Kohsuke Kawaguchi

Added pre-checkout method.

This method is called after assinging the workspace to the build, but before SCM checkout. Can be implemented by BuildWrappers.
上级 22d2dc48
...@@ -412,6 +412,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs ...@@ -412,6 +412,7 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
workspace = lease.path.getRemote(); workspace = lease.path.getRemote();
node.getFileSystemProvisioner().prepareWorkspace(AbstractBuild.this,lease.path,listener); node.getFileSystemProvisioner().prepareWorkspace(AbstractBuild.this,lease.path,listener);
preCheckout(launcher,listener);
checkout(listener); checkout(listener);
if (!preBuild(listener,project.getProperties())) if (!preBuild(listener,project.getProperties()))
...@@ -489,6 +490,25 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs ...@@ -489,6 +490,25 @@ public abstract class AbstractBuild<P extends AbstractProject<P,R>,R extends Abs
return l; return l;
} }
/**
* Run preCheckout on {@link BuildWrapper}s
*
* @param launcher
* The launcher, never null.
* @param listener
* Never null, connected to the main build output.
* @throws IOException
* @throws InterruptedException
*/
private void preCheckout(Launcher launcher, BuildListener listener) throws IOException, InterruptedException{
if (project instanceof BuildableItemWithBuildWrappers) {
BuildableItemWithBuildWrappers biwbw = (BuildableItemWithBuildWrappers) project;
for (BuildWrapper bw : biwbw.getBuildWrappersList())
bw.preCheckout(AbstractBuild.this,launcher,listener);
}
}
private void checkout(BuildListener listener) throws Exception { private void checkout(BuildListener listener) throws Exception {
try { try {
for (int retryCount=project.getScmCheckoutRetryCount(); ; retryCount--) { for (int retryCount=project.getScmCheckoutRetryCount(); ; retryCount--) {
......
...@@ -201,6 +201,28 @@ public abstract class BuildWrapper extends AbstractDescribableImpl<BuildWrapper> ...@@ -201,6 +201,28 @@ public abstract class BuildWrapper extends AbstractDescribableImpl<BuildWrapper>
return logger; return logger;
} }
/**
* Provides an opportunity for a {@link BuildWrapper} to perform some actions before SCM checkout.
*
* <p>
* This hook is called early on in the build (before {@link #setUp(AbstractBuild, Launcher, BuildListener)},
* but after {@link #decorateLauncher(AbstractBuild, Launcher, BuildListener)} is invoked.)
* The typical use is delete existing workspace before new build starts etc.
*
* <p>
* The default implementation is no-op.
*
* @param build
* The build in progress for which this {@link BuildWrapper} is called. Never null.
* @param launcher
* The launcher. Never null.
* @param listener
* Connected to the build output. Never null. Can be used for error reporting.
*
*/
public void preCheckout(AbstractBuild build, Launcher launcher, BuildListener listener) throws IOException, InterruptedException{
}
/** /**
* {@link Action} to be displayed in the job page. * {@link Action} to be displayed in the job page.
* *
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册