Skip to content

Commit

Permalink
[FIXED JENKINS-13888] Add option to turn off default Ant excludes fro…
Browse files Browse the repository at this point in the history
…m workspace archive.
  • Loading branch information
abayer committed May 24, 2012
1 parent 9549828 commit 0bfecda
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 10 deletions.
5 changes: 2 additions & 3 deletions pom.xml
Expand Up @@ -24,10 +24,9 @@ THE SOFTWARE.
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jvnet.hudson.plugins</groupId>
<groupId>org.jenkins-ci.plugins</groupId>
<artifactId>plugin</artifactId>
<version>1.350</version>
<relativePath>../pom.xml</relativePath>
<version>1.463</version>
</parent>

<artifactId>clone-workspace-scm</artifactId>
Expand Down
Expand Up @@ -87,12 +87,17 @@ public class CloneWorkspacePublisher extends Recorder {
*/
private final String archiveMethod;

/**
* If true, don't use the Ant default file glob excludes.
*/
private final boolean overrideDefaultExcludes;
@DataBoundConstructor
public CloneWorkspacePublisher(String workspaceGlob, String workspaceExcludeGlob, String criteria, String archiveMethod) {
public CloneWorkspacePublisher(String workspaceGlob, String workspaceExcludeGlob, String criteria, String archiveMethod, boolean overrideDefaultExcludes) {
this.workspaceGlob = workspaceGlob.trim();
this.workspaceExcludeGlob = Util.fixEmptyAndTrim(workspaceExcludeGlob);
this.criteria = criteria;
this.archiveMethod = archiveMethod;
this.overrideDefaultExcludes = overrideDefaultExcludes;
}

public BuildStepMonitor getRequiredMonitorService() {
Expand Down Expand Up @@ -120,6 +125,9 @@ public String getArchiveMethod() {
return archiveMethod;
}

public boolean getOverrideDefaultExcludes() {
return overrideDefaultExcludes;
}

@Override
public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListener listener) throws InterruptedException {
Expand Down Expand Up @@ -166,7 +174,7 @@ public boolean perform(AbstractBuild<?,?> build, Launcher launcher, BuildListene
}
// This means we found something.
if((includeMsg==null) && (excludeMsg==null)) {
DirScanner globScanner = new DirScanner.Glob(realIncludeGlob, realExcludeGlob);
DirScanner globScanner = new DirScanner.Glob(realIncludeGlob, realExcludeGlob, !overrideDefaultExcludes);
build.addAction(snapshot(build, ws, globScanner, listener, archiveMethod));

// Find the next most recent build meeting this criteria with an archived snapshot.
Expand Down
Expand Up @@ -42,4 +42,7 @@ THE SOFTWARE.
<f:option value="ZIP" selected='${instance.archiveMethod=="ZIP"}'>${%Zipped}</f:option>
</select>
</f:entry>
<f:entry title="${%Override Default Ant Excludes}" field="overrideDefaultExcludes">
<f:checkbox />
</f:entry>
</j:jelly>
Expand Up @@ -62,12 +62,12 @@ public void testBasicCloning() throws Exception {

public void testSlaveCloning() throws Exception {
FreeStyleProject parentJob = createCloneParentProject();
parentJob.setAssignedLabel(createSlave(new Label("parentSlave")).getSelfLabel());
parentJob.setAssignedLabel(createSlave(Label.get("parentSlave")).getSelfLabel());

buildAndAssertSuccess(parentJob);

FreeStyleProject childJob = createCloneChildProject();
childJob.setAssignedLabel(createSlave(new Label("childSlave")).getSelfLabel());
childJob.setAssignedLabel(createSlave(Label.get("childSlave")).getSelfLabel());
buildAndAssertSuccess(childJob);

FreeStyleBuild fb = childJob.getLastBuild();
Expand All @@ -78,7 +78,7 @@ public void testSlaveCloning() throws Exception {
}

public void testGlobCloning() throws Exception {
FreeStyleProject parentJob = createCloneParentProject(new CloneWorkspacePublisher("moduleB/**/*", null, "Any", "ZIP"));
FreeStyleProject parentJob = createCloneParentProject(new CloneWorkspacePublisher("moduleB/**/*", null, "Any", "ZIP", false));

buildAndAssertSuccess(parentJob);

Expand Down Expand Up @@ -133,7 +133,7 @@ public void testNotFailedCriteriaDoesAcceptUnstable() throws Exception {
}

public void testNotFailedParentCriteriaDoesNotArchiveFailure() throws Exception {
FreeStyleProject parentJob = createCloneParentProject(new CloneWorkspacePublisher("**/*", null, "Not Failed", "ZIP"));
FreeStyleProject parentJob = createCloneParentProject(new CloneWorkspacePublisher("**/*", null, "Not Failed", "ZIP", false));

parentJob.getBuildersList().add(new FailureBuilder());

Expand Down Expand Up @@ -191,7 +191,7 @@ private FreeStyleProject createCloneChildProject(CloneWorkspaceSCM cws) throws E
}

private FreeStyleProject createCloneParentProject() throws Exception {
return createCloneParentProject(new CloneWorkspacePublisher("**/*", null, "Any", "zip"));
return createCloneParentProject(new CloneWorkspacePublisher("**/*", null, "Any", "zip", false));
}

private FreeStyleProject createCloneParentProject(CloneWorkspacePublisher cwp) throws Exception {
Expand Down

5 comments on commit 0bfecda

@davehunt
Copy link

Choose a reason for hiding this comment

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

Any chance of pushing a release so users can take advantage of this fix?

@davehunt
Copy link

Choose a reason for hiding this comment

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

@abayer
Copy link
Member Author

@abayer abayer commented on 0bfecda Aug 17, 2012

Choose a reason for hiding this comment

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

Sorry - pushing a release now.

@davehunt
Copy link

Choose a reason for hiding this comment

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

Thanks @abayer. I now see 0.5 listed on the plugin page but not via plugin manager in Jenkins. Is there anything else to do or do we just need to wait?

@davehunt
Copy link

Choose a reason for hiding this comment

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

Ignore my last comment, I forced a refresh and there it is! Many thanks.

Please sign in to comment.