File Operations Plugin fileCopyOperation - Jenkins pipeline
fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: 'C:\workspace\Hello\**', targetLocation: 'F:\Test\Sample')])
You have mention the below line which is telling to taking everything i.e. xxx,yyy folders so its doing it's job correctly
C:\workspace\Hello**
you will have to mention in the excludes section which folder to exclude i.e. yyy in this case.
For simplicity's sake
fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: 'C:\workspace\Hello\xxx\**', targetLocation: 'F:\Test\Sample')])
The above copies from xxx folder to F:\Test\Sample and the below copies from yyy folder to F:\Test\Example
fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: 'C:\workspace\Hello\yyy\**', targetLocation: 'F:\Test\Example')])
Related videos on Youtube
Sri
Updated on June 04, 2022Comments
-
Sri about 2 years
I am working on File Operations Plugin- fileCopyOperation in Jenkins pipeline (Jenkins version - v2.73.2 ,Jenkins pipeline - 2.5) i need to copy file from one location to the other location with different folder structure.
Expected:
Source
C:\workspace\Hello -> xxx,yyy [xxx directory contains sub-directories and files aaa,bbb,ccc.txt; yyy dir contains web.xml,sec.txt]
Destination
F:\Test\Sample -> aaa,bbb,ccc.txt
F:\Test\Example -> web.xml,sec.txtBelow is the command i am using which is copying whole Hello directory not the way it is behaving as expected.
fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: 'C:\workspace\Hello\**', targetLocation: 'F:\Test\Sample')])
Present:
F:\Test\Sample\workspace\Hello -> xxx,yyy
Appreciate your inputs.
-
rohit thomas about 6 years@Sri if this helped you in solving your issue please select it as the correct answer so that others, who face this issue will know what needs to be done
-
Sri about 6 yearsThanks for the reply and apologize for responding late. This makes sense, however, its actually copying files in folder structure as F:\Test\Sample\workspace\Hello\xxx** but expected is to copy files direct to the F:\Test\Sample**
-
rohit thomas about 6 years@Sri I think that's an existing issue as mentioned here in the comments wiki.jenkins.io/display/JENKINS/File+Operations+Plugin ... Why not use a simple 'cp' command to achieve what you want