-
Notifications
You must be signed in to change notification settings - Fork 163
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[JENKINS-34122] Exclude output file from itself #18
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -90,7 +90,7 @@ protected Void run() throws Exception { | |
listener.getLogger().println("Writing zip file of " + source.getRemote() | ||
+ " filtered by [" + step.getGlob() + "] to " + destination.getRemote()); | ||
} | ||
int count = source.act(new ZipItFileCallable(destination, step.getGlob())); | ||
int count = source.act(new ZipItFileCallable(destination, step.getGlob(), step.getZipFile())); | ||
listener.getLogger().println("Zipped " + count + " entries."); | ||
if (step.isArchive()) { | ||
listener.getLogger().println("Archiving " + destination.getRemote()); | ||
|
@@ -112,16 +112,19 @@ protected Void run() throws Exception { | |
static class ZipItFileCallable extends MasterToSlaveFileCallable<Integer> { | ||
final FilePath zipFile; | ||
final String glob; | ||
private final String zipFileName; | ||
|
||
public ZipItFileCallable(FilePath zipFile, String glob) { | ||
public ZipItFileCallable(FilePath zipFile, String glob, String zipFileName) { | ||
this.zipFile = zipFile; | ||
this.glob = StringUtils.isBlank(glob) ? "**/*" : glob; | ||
this.zipFileName = zipFileName; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not needed use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that if you add the full path to the exclude list you should be safe. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for the same reason I've told to @jtnord, the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. you can try to change |
||
} | ||
|
||
@Override | ||
public Integer invoke(File dir, VirtualChannel channel) throws IOException, InterruptedException { | ||
Archiver archiver = ArchiverFactory.ZIP.create(zipFile.write()); | ||
FileSet fs = Util.createFileSet(dir, glob); | ||
fs.setExcludes(zipFileName); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. at this point you must know where the You just need to check that the canonical files location are not the same before calling archiver.visit. |
||
DirectoryScanner scanner = fs.getDirectoryScanner(new org.apache.tools.ant.Project()); | ||
try { | ||
for (String path : scanner.getIncludedFiles()) { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
isn;t this just
zipFile.getName()
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
what if you are writing a zip file in
/foo/bar/wibble/zip.zip
and you are archiving/bob/jane/freddy
which contains a file calledzip.zip
- but not the samezip.zip
as you are writing to?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
zipFile.getName()
wouldn't return the correct value. If youzip
totest/archive.zip
, thenzipFile.getName()
isarchive
and is not excluded correctly from theFileSet
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hence I think we need to find a way to exclude a specific absolute path, so that it can work in all occations.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm trying to make a unit test with @jtnord scenario, but either my changeset doesn't introduce this regression, or I didn't reproduce the scenario correctly.