Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Files/changes added to allow clean before checkout resolving JENKINS-…
- Loading branch information
1 parent
bc57353
commit fb12fed
Showing
4 changed files
with
87 additions
and
1 deletion.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/hudson/plugins/git/extensions/impl/CleanBeforeCheckout.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package hudson.plugins.git.extensions.impl; | ||
|
||
import hudson.Extension; | ||
import hudson.model.AbstractBuild; | ||
import hudson.model.BuildListener; | ||
import hudson.model.TaskListener; | ||
import hudson.plugins.git.GitException; | ||
import hudson.plugins.git.GitSCM; | ||
import hudson.plugins.git.extensions.GitSCMExtension; | ||
import hudson.plugins.git.extensions.GitSCMExtensionDescriptor; | ||
|
||
import org.jenkinsci.plugins.gitclient.CloneCommand; | ||
import org.jenkinsci.plugins.gitclient.FetchCommand; | ||
import org.jenkinsci.plugins.gitclient.GitClient; | ||
import org.kohsuke.stapler.DataBoundConstructor; | ||
|
||
import java.io.IOException; | ||
|
||
/** | ||
* git-clean before the checkout. | ||
* | ||
* @author David S Wang | ||
*/ | ||
public class CleanBeforeCheckout extends GitSCMExtension { | ||
@DataBoundConstructor | ||
public CleanBeforeCheckout() { | ||
} | ||
|
||
@Override | ||
public void decorateFetchCommand(GitSCM scm, GitClient git, TaskListener listener, FetchCommand cmd) throws IOException, InterruptedException, GitException { | ||
listener.getLogger().println("Cleaning workspace"); | ||
git.clean(); | ||
// TODO: revisit how to hand off to SubmoduleOption | ||
for (GitSCMExtension ext : scm.getExtensions()) { | ||
ext.onClean(scm, git); | ||
} | ||
} | ||
|
||
@Extension | ||
public static class DescriptorImpl extends GitSCMExtensionDescriptor { | ||
@Override | ||
public String getDisplayName() { | ||
return "Clean before checkout"; | ||
} | ||
} | ||
} |
8 changes: 8 additions & 0 deletions
8
src/main/resources/hudson/plugins/git/extensions/impl/CleanBeforeCheckout/help.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
<div> | ||
Clean up the workspace before every checkout by deleting all untracked files and directories, | ||
including those which are specified in <tt>.gitignore</tt>. | ||
It also resets all <em>tracked</em> files to their versioned state. | ||
This ensures that the workspace is | ||
in the same state as if you cloned and checked out in a brand-new empty directory, and ensures | ||
that your build is not affected by the files generated by the previous build. | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters