Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[FIXED JENKINS-37447]: Publish artifacts to S3 bucket drops character…
…s before

wildcard
  • Loading branch information
Jimilian committed Apr 21, 2017
1 parent 859407a commit 973d27d
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/hudson/plugins/s3/FileHelper.java
Expand Up @@ -51,8 +51,8 @@ public static int getSearchPathLength(String workSpace, String filterExpanded, b


if (indexOfWildCard > 0) {
final String s = pathWithFilter.substring(0, indexOfWildCard);
return s.length();
int folderNameEnds = pathWithFilter.substring(0, indexOfWildCard).lastIndexOf(File.separatorChar);
return pathWithFilter.substring(0, folderNameEnds).length() + 1;
} else {
return file2.getParent().length() + 1;
}
Expand Down
11 changes: 11 additions & 0 deletions src/test/java/hudson/plugins/s3/FileHelperTest.java
Expand Up @@ -114,6 +114,17 @@ public void testGetStartIndexWithAsteriskButKeepStructure() throws Exception {
assertEquals(shouldBeCut.length(), startIndex);
}

@Test
public void testGetStartIndexWithAsteriskInTheMiddle() throws Exception {
String workspace = "/var/lib/jenkins/jobs/workspace";
String folder = "tests/some_name.*.0.extension";

final String shouldBeCut = "/var/lib/jenkins/jobs/workspace/tests/";

int startIndex = FileHelper.getSearchPathLength(workspace, folder, false);
assertEquals(shouldBeCut.length(), startIndex);
}

@Test
public void testGetStartIndexWithAsteriskInsideButKeepStructure() throws Exception {
String workspace = "/var/lib/jenkins/jobs/workspace";
Expand Down

0 comments on commit 973d27d

Please sign in to comment.