Sri
Sri

Reputation: 479

File Operations Plugin fileCopyOperation - Jenkins pipeline

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.txt

Below 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.

Upvotes: 2

Views: 24369

Answers (1)

rohit thomas
rohit thomas

Reputation: 2312

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')])

Upvotes: 2

Related Questions