Zip Pipeline Utility - Recursively Zip Sub Dir and Files - jenkins

Can I use this utility to recursively zip files and sub-dirs under a dir?

As specified in the documentation , if I do not set value for "glob" , all the files and dirs are getting included as part of the zip file.

Related

Zip all the files within the folder in jenkins workspace

I have some files in Jenkins work space. I want all the files to be zipped and zip should now include the root folder and should include only the contents within the folder.
I have already tried using file operation plugin which actually zips the files. But problem using this plugin is that all the files are inside an root folder. What i need is as soon as i unzip i should only get the files and not the folder.
Try and use the manven assembly plugin.
You can then configure it to include file without taking its path folders, using:
<includeBaseDirectory>false</includeBaseDirectory>-
fileSets
You can simply do it using terminal
got to the root directory or the directory that have all the files you want then :
tar chvfz workspace.tar.gz *
will zip all the files in the workspace in workspace.tar.gz
if you wanna zip specific files u can list them instead of using *

How to use ant unzip to include nested zip file?

I have an ear file which includes war files and jars.
I'm using the unzip task to unzip the ear.
the problem is that I want to see in my destination folder the war files etracted as well.
for eample:
I have c:\example.ear inside i have 1.jar, 2.jar 3.war, 4.war
after extractio I would like to see:
c:\exmple
3.war (d)
4.war (d)
1.jar (f)
2.jar (f)
when d=directory f=file
well, apperantaly you cannot create a folder with the same name of a war file in the same location.
So what I did in the end was move the war file to a tmp folder and unzip from there to the previous location.
solve the trick :-)

How do I create a fileset in Apache Ant that includes child files but exclude the containing directory?

I am able to create a fileset which includes certain directories. I am including this fileset to a copy. I want to take the child file and copy it without taking the parent folder.
My source structure is:
root
Folder1
Folder2
script.js
Folder3
script2.js
So I want script.js and script2.js copied, but in the destination directory I get Folder2 and Folder3 included.
I'm out of depth. Help would be appreciated.
Simply use copy task with flatten attribute set to true :
Ignore the directory structure of the source files, and copy all files
into the directory specified by the todir attribute. Note that you can
achieve the same effect by using a flatten mapper.

How to copy files into a zip file using ANT script?

I want to copy few files into an existing zip file using ANT script.
Is there any task available for that? Or do I need to unzip the zip file then copy the needed files and zip again?
Straight from the documentation of the zip task:
The update parameter controls what happens if the ZIP file already
exists. When set to yes, the ZIP file is updated with the files
specified. (New files are added; old files are replaced with the new
versions.)
If you have an existing zip file called perlscr.zip, you can add for example, a file called backup.sh in the shellscr directory using the Ant Zip task:
<zip destfile="perlscr.zip"
basedir="shellscr"
includes="backup.sh"
update="true"/>

Delete generated files when original is modified with Apache Ant

I want to delete the generated files (".tmp" and ".bak") in the build directory when the source file (".xml)" is modified with Apache Ant. All files have the same name, but different extentions.
I'm not able to create the fileset to do this.
You can use a file mapper in place of a fileset.

Resources