Jenkins Files to archive pattern - ant

In the Jenkins copy artifacts plugins, it follows ant includes attributes of fileset.
If I give Output/**/*
it copies everything including the Output folder.
How can I tell to copy only everything inside Output folder but not the Output folder iteself.
source: Output/v2.1/xxx/*.*
Destination:v2.1/xxx/*.*

The answer is, its probably not possible in copy artifact plugin.
But the same objective can be reachable by another plugin, called Artifact deployer plugin. In that plugin when you deploy the artifact to local or remote server, you can specify the base directory, so the artifact is copied from the base directory excluding the base directory. In this case if I specify my base directory as Output then it copies what is inside the output directory.

Related

Jenkins - how to add additional folder with subfolders, e.g. Images

I have a web project that Jenkins is building perfectly and pushing to Octopus Deploy.
I now have an additional folder, with subfolders, e.g. Images, which I need to include.
This is not directly part of the .net build and we used to copy it manually afterward.
Do I need a specific plugin which I can use to select the folder to include?
Which plugin?
Where in the build process does this plugin run?
The build and deploy to octopus is done in one step -
where do I fit in this additional folder to be included in the push to the octopus?
This is not directly part of the .net build and we used to copy it manually afterward.
If your Jenkins server can access that addition folder in a shared path, add a pre-build step which, as an "Executable Windows batch command" step, would copy that folder into the Jenkins workspace.
No plugin needed here.
Once that is done, you would still need to modify Octopus accordingly, to take into account that new copied folder.
See:
"How to add a folder to a nuspec file"
"How to include directories recursively in NuSpec file"

Jenkins - Publish Over SSH Plugin: How to copy directory

I'm trying to use Jenkins' Publish Over SSH plugin to copy all files AND sub-directories of some given directory, but so far, I've only able to copy files and NOT directory.
I have a directory named foo in my workspace, and during the build, I want to copy everything in this directory to a remote server.
I've tried this pattern foo/**, but it doesn't copy all sub-directories.
Any suggestion? Or this is not the plugin I should be using?
Thanks
For recursive copy of directory you should give
foo/**/*
I verified this on my laptop using locally deploying Jenkins. It works fine.

How to copy the content of sub-dir without a custom Ant task?

I'm working with Jenkins 2 and trying to copy artifacts between jobs and in turn to an S3 bucket.
I have a simple web build which produces artifacts in /dist/public which I'd like to upload into the S3 bucket.
So once the job completes, I have a folder /dist in the workspace root. Jenkins gives you the ability to copy artifacts between jobs which leverages Ant's fileset.
The issue I'm having is that this is a restricted subset of Ant and all you're provided is include & exclude paths.
I can use dist/public/**/** however this copies the parent directories across also.
What I would prefer is to only copy the content of public/ but after doing some reading it seems this may be difficult to do without a custom Ant tasks, etc.
If you copy files by Ant, you should set:
<fileset dir="/dist/public"/>
at you copy task, or you can use flatten attribute.
If you use Jenkins artefact collector (as I do), I think now you have to copy this files to workspace root (see: Copy Artifact Plugin).

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.

Publishing to Artifactory using Jenkins

I am trying to use the Generic Jenkins-Artifactory plugin to deploy the contents of the Jenkins build workspace into Artifactory. This seems to be somewhat fine using the following wildcards
Web\*.msi=>Testing\Web
Web\DeploymentSettings\*.xml=>Testing\Web\DeploymentSettings
Database\Scripts\**=>Testing\Database
However, when it comes to moving the contents of 'Database\Scripts' from the Jenkins workspace, empty folders under 'Database\Scripts' do not get copied into Artifactory. Non-empty folders however are copied successfully. It is important that I maintain the directory integrity/structure so it's a must that I copy these across.
I have considered placing empty text files in the empty directories to have them copy over successfully but I don't want to "pollute" the package.
Please help :-)
Thanks!
Looks like there is no workaround -other than dummy files in the directories.
I see some bugs in Jenkins releated to handling empty directories.
JENKINS-7260 Clone workspace doesn't copy empty directories when cloning entire workspace
JENKINS-20654Empty folders are not copied to the slave
Could you check if answer posted in Hudson: Copy artifact from master to slave fails helps?

Resources