Skip to content
Permalink
Browse files

[FIXED JENKINS-13831] Option to create empty directories

  • Loading branch information
bap2000 committed Sep 28, 2012
1 parent e96e1a6 commit 02b6aa8c02abf62072f3ecdde9020932bd0f3a55
@@ -45,14 +45,14 @@

BapSshTransfer(final String sourceFiles, final String remoteDirectory, final String removePrefix,
final boolean remoteDirectorySDF, final boolean flatten, final String execCommand, final int execTimeout) {
this(sourceFiles, null, remoteDirectory, removePrefix, remoteDirectorySDF, flatten, execCommand, execTimeout, false, false);
this(sourceFiles, null, remoteDirectory, removePrefix, remoteDirectorySDF, flatten, execCommand, execTimeout, false, false, false);
}

@DataBoundConstructor
public BapSshTransfer(final String sourceFiles, final String excludes, final String remoteDirectory, final String removePrefix,
final boolean remoteDirectorySDF, final boolean flatten, final String execCommand, final int execTimeout,
final boolean usePty, final boolean noDefaultExcludes) {
super(sourceFiles, excludes, remoteDirectory, removePrefix, remoteDirectorySDF, flatten, false, noDefaultExcludes);
final boolean usePty, final boolean noDefaultExcludes, final boolean makeEmptyDirs) {
super(sourceFiles, excludes, remoteDirectory, removePrefix, remoteDirectorySDF, flatten, false, noDefaultExcludes, makeEmptyDirs);
this.execCommand = execCommand;
this.execTimeout = execTimeout;
this.usePty = usePty;
@@ -48,14 +48,6 @@ public String getDisplayName() {
return Messages.transfer_descriptor_displayName();
}

public boolean canUseExcludes() {
return BPTransfer.canUseExcludes();
}

public boolean canUseNoDefaultExcludes() {
return BPTransfer.canUseNoDefaultExcludes();
}

public FormValidation doCheckExecTimeout(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}
@@ -46,12 +46,13 @@
private final boolean cleanRemote;
private final boolean usePty;
private final boolean noDefaultExcludes;
private final boolean makeEmptyDirs;

@DataBoundConstructor
public SshOverrideTransferDefaults(final String sourceFiles, final String excludes, final String removePrefix,
final String remoteDirectory, final boolean flatten, final boolean remoteDirectorySDF,
final boolean cleanRemote, final String execCommand, final int execTimeout, final boolean usePty,
final boolean noDefaultExcludes) {
final boolean noDefaultExcludes, final boolean makeEmptyDirs) {
this.cleanRemote = cleanRemote;
this.excludes = excludes;
this.execCommand = execCommand;
@@ -63,6 +64,7 @@ public SshOverrideTransferDefaults(final String sourceFiles, final String exclud
this.sourceFiles = sourceFiles;
this.usePty = usePty;
this.noDefaultExcludes = noDefaultExcludes;
this.makeEmptyDirs = makeEmptyDirs;
}

public String getExecCommand() {
@@ -113,6 +115,10 @@ public boolean isNoDefaultExcludes() {
return noDefaultExcludes;
}

public boolean isMakeEmptyDirs() {
return makeEmptyDirs;
}

@Extension
public static class SshOverrideTransferDefaultsDescriptor extends Descriptor<SshOverrideTransferDefaults> {

@@ -121,14 +127,6 @@ public String getDisplayName() {
return "SshOverrideTransferDefaultsDescriptor - not visible ...";
}

public boolean canUseExcludes() {
return BPTransfer.canUseExcludes();
}

public boolean canUseNoDefaultExcludes() {
return BPTransfer.canUseNoDefaultExcludes();
}

public FormValidation doCheckExecTimeout(@QueryParameter final String value) {
return FormValidation.validateNonNegativeInteger(value);
}
@@ -50,17 +50,17 @@

<f:advanced>

<j:if test="${descriptor.canUseExcludes()}">
<f:entry title="${m.excludes()}" field="excludes">
<f:textbox default="${defaults.transfer.excludes}"/>
</f:entry>
</j:if>

<j:if test="${descriptor.canUseNoDefaultExcludes()}">
<f:entry title="${m.noDefaultExcludes()}" field="noDefaultExcludes">
<f:checkbox default="${defaults.transfer.noDefaultExcludes}"/>
</f:entry>
</j:if>
<f:entry title="${m.excludes()}" field="excludes">
<f:textbox default="${defaults.transfer.excludes}"/>
</f:entry>

<f:entry title="${m.noDefaultExcludes()}" field="noDefaultExcludes">
<f:checkbox default="${defaults.transfer.noDefaultExcludes}"/>
</f:entry>

<f:entry title="${m.makeEmptyDirs()}" field="makeEmptyDirs">
<f:checkbox default="${defaults.transfer.makeEmptyDirs}"/>
</f:entry>

<f:entry title="${m.flatten()}" field="flatten">
<f:checkbox default="${defaults.transfer.flatten}"/>
@@ -0,0 +1,28 @@
<!--
~ The MIT License
~
~ Copyright (C) 2012 by Anthony Robinson
~
~ Permission is hereby granted, free of charge, to any person obtaining a copy
~ of this software and associated documentation files (the "Software"), to deal
~ in the Software without restriction, including without limitation the rights
~ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
~ copies of the Software, and to permit persons to whom the Software is
~ furnished to do so, subject to the following conditions:
~
~ The above copyright notice and this permission notice shall be included in
~ all copies or substantial portions of the Software.
~
~ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
~ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
~ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
~ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
~ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
~ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
~ THE SOFTWARE.
-->

<div>
<p>The default behaviour of this plugin is to match files, and then create any directories required to preserve the paths to the files.<br />
Selecting this option will create any directories that match the Source files pattern, even if empty.</p>
</div>
@@ -40,16 +40,15 @@
<f:entry title="${%execCommand}" field="execCommand">
<poj:textarea minRows="1" default="${defaults.transfer.execCommand}"/>
</f:entry>
<j:if test="${descriptor.canUseExcludes()}">
<f:entry title="${m.excludes()}" field="excludes">
<f:textbox default="${defaults.transfer.excludes}"/>
</f:entry>
</j:if>
<j:if test="${descriptor.canUseNoDefaultExcludes()}">
<f:entry title="${m.noDefaultExcludes()}" field="noDefaultExcludes">
<f:checkbox default="${defaults.transfer.noDefaultExcludes}"/>
</f:entry>
</j:if>
<f:entry title="${m.excludes()}" field="excludes">
<f:textbox default="${defaults.transfer.excludes}"/>
</f:entry>
<f:entry title="${m.noDefaultExcludes()}" field="noDefaultExcludes">
<f:checkbox default="${defaults.transfer.noDefaultExcludes}"/>
</f:entry>
<f:entry title="${m.makeEmptyDirs()}" field="makeEmptyDirs">
<f:checkbox default="${defaults.transfer.makeEmptyDirs}"/>
</f:entry>
<f:entry title="${m.flatten()}" field="flatten">
<f:checkbox default="${defaults.transfer.flatten}"/>
</f:entry>
@@ -294,7 +294,7 @@ private void assertDisconnect() throws Exception {
expect(mockSession.openChannel("exec")).andReturn(exec);
expect(mockSession.getTimeout()).andReturn(timeout);
mockControl.replay();
bapSshClient.endTransfers(new BapSshTransfer("", "", "", "", false, false, command, timeout, true, false));
bapSshClient.endTransfers(new BapSshTransfer("", "", "", "", false, false, command, timeout, true, false, false));
assertTrue(exec.isUsePty());
}

@@ -287,8 +287,8 @@ private BapSshClient assertCreateClientWithDefaultKey(final boolean disableExec)
@Test public void testDontConnectSftpIfNoSourceFilesInAnyTransfers() throws Exception {
final BapSshCommonConfiguration defaultKeyInfo = new BapSshCommonConfiguration(TEST_PASSPHRASE, null, null, false);
hostConfig = createWithDefaultKeyInfo(mockJSch, defaultKeyInfo);
final BapSshTransfer transfer1 = new BapSshTransfer("", "", "", "", false, false, "ls -la", 10000, false, false);
final BapSshTransfer transfer2 = new BapSshTransfer("", "", "", "", false, false, "pwd", 10000, false, false);
final BapSshTransfer transfer1 = new BapSshTransfer("", "", "", "", false, false, "ls -la", 10000, false, false, false);
final BapSshTransfer transfer2 = new BapSshTransfer("", "", "", "", false, false, "pwd", 10000, false, false, false);
final ArrayList<BapSshTransfer> transfers = new ArrayList<BapSshTransfer>();
transfers.addAll(Arrays.asList(transfer1, transfer2));
final BapSshPublisher publisher = new BapSshPublisher(hostConfig.getName(), false, transfers, false, false, null, null, null);
@@ -79,7 +79,7 @@ public JSch createJSch() {
new JenkinsTestHelper().setGlobalConfig(commonConfig, testHostConfig);
final String dirToIgnore = "target";
final int execTimeout = 10000;
final BapSshTransfer transfer = new BapSshTransfer("**/*", null, "sub-home", dirToIgnore, false, false, "", execTimeout, false, false);
final BapSshTransfer transfer = new BapSshTransfer("**/*", null, "sub-home", dirToIgnore, false, false, "", execTimeout, false, false, false);
final BapSshPublisher publisher = new BapSshPublisher(testHostConfig.getName(), false,
new ArrayList<BapSshTransfer>(Collections.singletonList(transfer)), false, false, null, null, null);
final BapSshPublisherPlugin plugin = new BapSshPublisherPlugin(
@@ -64,7 +64,7 @@ public void testLoadR0x1Minimal() throws Exception {

final int expectedExecTimeout = 120000;
final List<BapSshTransfer> transfers = Collections.singletonList(
new BapSshTransfer("**/*", null, "", "", false, false, "", expectedExecTimeout, false, false));
new BapSshTransfer("**/*", null, "", "", false, false, "", expectedExecTimeout, false, false, false));
final BapSshPublisher publisher = newPublisher("default", false, new ArrayList<BapSshTransfer>(transfers));
final ArrayList<BapSshPublisher> publishers = new ArrayList<BapSshPublisher>();
publishers.add(publisher);
@@ -87,23 +87,23 @@ public void testLoadR0x12() throws Exception {
assertPublisherPluginConfiguration(DEFAULT_EXEC_TIMEOUT);

final List<BapSshTransfer> builderTransfers = Collections.singletonList(
new BapSshTransfer("builderC/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false));
new BapSshTransfer("builderC/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false, false));
final List<BapSshPublisher> builderPublishers = Collections.singletonList(
newPublisher(configName('c'), false, new ArrayList<BapSshTransfer>(builderTransfers)));
final BapSshBuilderPlugin expectedBuilderPlugin = new BapSshBuilderPlugin(new ArrayList<BapSshPublisher>(builderPublishers),
true, false, false, "", null);
assertEquals(expectedBuilderPlugin, getConfiguredBuilderPlugin());

final List<BapSshTransfer> preTransfers = Collections.singletonList(
new BapSshTransfer("beforeA/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false));
new BapSshTransfer("beforeA/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false, false));
final List<BapSshPublisher> prePublishers = Collections.singletonList(
newPublisher(configName('a'), false, new ArrayList<BapSshTransfer>(preTransfers)));
final BapSshPreBuildWrapper expectedPreBuildPlugin = new BapSshPreBuildWrapper(new ArrayList<BapSshPublisher>(prePublishers),
false, true, false, "", null);
assertEquals(expectedPreBuildPlugin, getConfiguredBuildWrapper(BapSshPreBuildWrapper.class));

final List<BapSshTransfer> postTransfers = Collections.singletonList(
new BapSshTransfer("afterD/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false));
new BapSshTransfer("afterD/", null, "", "", false, false, "", DEFAULT_EXEC_TIMEOUT, false, false, false));
final List<BapSshPublisher> postPublishers = Collections.singletonList(
newPublisher(configName('d'), false, new ArrayList<BapSshTransfer>(postTransfers)));
final BapSshPostBuildWrapper expectedPostBuildPlugin = new BapSshPostBuildWrapper(new ArrayList<BapSshPublisher>(postPublishers),
@@ -132,16 +132,16 @@ private void assertGlobalConfig() {

private void assertPublisherPluginConfiguration(final int transfer11Timeout) {
final int transfer12Timeout = 15000;
final BapSshTransfer transfer11 = new BapSshTransfer("", null, "", "", false, false, "date", transfer11Timeout, false, false);
final BapSshTransfer transfer11 = new BapSshTransfer("", null, "", "", false, false, "date", transfer11Timeout, false, false, false);
final BapSshTransfer transfer12 = new BapSshTransfer("target/*.jar", null, "'builds/'yyyy_MM_dd/'build-${BUILD_NUMBER}'", "target",
true, true, "ls -la /tmp", transfer12Timeout, false, false);
true, true, "ls -la /tmp", transfer12Timeout, false, false, false);
final ArrayList<BapSshTransfer> transfers1 = new ArrayList<BapSshTransfer>();
transfers1.add(transfer11);
transfers1.add(transfer12);
final BapSshPublisher publisher1 = newPublisher(configName('a'), true, transfers1);
final int transfer21Timeout = 10000;
final BapSshTransfer transfer21 = new BapSshTransfer("out\\dist\\**\\*", null, "", "out\\dist", false, false, "",
transfer21Timeout, false, false);
transfer21Timeout, false, false, false);
final ArrayList<BapSshTransfer> transfers2 = new ArrayList<BapSshTransfer>();
transfers2.add(transfer21);
final BapSshPublisher publisher2 = newPublisher(configName('c'), false, transfers2);

0 comments on commit 02b6aa8

Please sign in to comment.