Zip all the files within the folder in jenkins workspace - jenkins

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 *

Related

TFS 2017 build Copy files from

In a build, we have Copy files from the task. The problem we have is the source folder itself is copied to the destination. We'd want the contents of the source folder to be copied to the destination folder, not the folder itself. Is there any way to do that?
I tried a wildcard but that doesn't work. It seems it needs a path itself. An issue of this could be that the source is named 'X' but the destination is named 'Y' (it was setup before this build and IIS is pointing to this folder). Can we have the source folder be renamed in the build maybe?
That would be name_of_sourcefolder\**\* for all files and subfolders of just name_of_sourcefolder\* for all files.
This has to be set in the Contents part of the task.

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 :-)

Jenkins: Copying Artifact (directory) from one Job to another

in Jenkins, I have a job downloadAgents that is responsible of creating a folder and populating it with some files. Then the folder is saved as an artifact with the following folder structure
dev\downloadAgents\target\dependency\ios
Then I need to copy the contents of the ios folder into the workspace of another job (into a specific folder).
I have added the Copy artifacts from another project step. And it does copy the artifacts, but it copies the full path
\dev\downloadIosAgents\target\dependency\ios
How can I tell jenkins to copy only one folder ios and everything that is inside it and, do not copy all folders that are before ios.
Also if there are already files in the destination folder, will it merge the 2 folders?
You can use regex for your copy (under "Artifacts to copy")-
dev\downloadAgents\target\dependency\ios***.*
** - all folders under ios
*.* - all file types
You can also specify the target directory, and you also have a flag for "Flatten directories". This will move all the files without the hierarchy of the folders (flat to your target directory)
Feel free to look at the plugin's home page:
https://wiki.jenkins-ci.org/display/JENKINS/Copy+Artifact+Plugin
In CopyArtifacts plugin specify the pattern: \dev\downloadIosAgents\target\dependency\ios\*.* or \dev\downloadIosAgents\target\dependency\ios\** - I don't remember exactly.
That should do the job.

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