Skip to content

[FIXED JENKINS-7260] Add an option to copy empty directories #12

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

Closed
wants to merge 2 commits into from
Closed

[FIXED JENKINS-7260] Add an option to copy empty directories #12

wants to merge 2 commits into from

Conversation

etiennebec
Copy link

The plugin mainly relies on jenkins-core API which implementation has changed a few times between 1.463 and 1.642, so it's actually quite difficult to add new features or to change its behavior.

The DirScanner.Glob doesn't archive empty directories because it actually generates a list of files to save and then create the correct directory tree to match the location of those files.

One workaround I found is to write a custom DirScanner (based on DirScanner.Filter) which actually scans the whole workspace, excludes files which are not part of the Ant pattern and automatically accepts directories whatever the Ant pattern is (see hudson.util.FileVisitor.FilterFileVisitor.visit method).

The pitfall is that you can't exclude directories anymore. At least I filter them at the top-level, meaning if your workspace contains dir1, dir2, dir3 and your include pattern is dir1/**, it won't copy dir2 and dir3.

That way I think I was able to minimize copy/paste and still relies on the jenkins-core API to actually do
anything.

Change-Id: Idc7f1a12ba8f58279cbd17f973afdb7d4a72ba05
The plugin mainly relies on jenkins-core API which implementation has changed a few times between 1.463 and 1.642,
so it's actually quite difficult to add new features or to change its behavior.

The DirScanner.Glob doesn't archive empty directories because it actually generates a list of files to save
and then create the correct directory tree to match the location of those files.

One workaround I found is to write a custom DirScanner (based on DirScanner.Filter) which actually scans the
whole workspace, excludes files which are not part of the Ant pattern and automatically accepts directories
whatever the Ant pattern is (see hudson.util.FileVisitor.FilterFileVisitor.visit method).

That way I think I was able to minimize copy/paste and still relies on the jenkins-core API to actually do
anything.

Change-Id: I1c3348b460674f5681e042bea9eada3b02e16b1e
@jenkinsadmin
Copy link
Member

Thank you for this pull request! Please check this document for how the Jenkins project handles pull requests.

@MarkEWaite MarkEWaite added the enhancement New features and improvements label Nov 28, 2022
@MarkEWaite MarkEWaite closed this Nov 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New features and improvements
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants