6

I'm starting with Jenkins pipelines, and I want to copy some video files from outside any jenkins directory to my job workspace directory. I'm using the File Operations Plugin to perform some file operations for other jobs I have. With that plugin, I'm able to copy files from inside my workspace to outside:

fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: "videos\\*.MTS", targetLocation: "H:\\home\\Videos")])

With this step, for example, I can copy 4 video files located in my workspace to the mentioned directory, located in another disk.

But I want to do the opposite. I want to copy video files from a source directory in the other disk to the workspace. I tried it in several ways, but seems that 'includes' field doesn't accept absolute paths. For example:

fileOperations([fileCopyOperation(excludes: '', flattenFiles: false, includes: "H:\\home\\Videos\\videos\\*.MTS", targetLocation: ".")])

This returned the following error in the console output:

File Copy Operation: FATAL: Expecting Ant GLOB pattern, but saw 'H:\home\Videos\videos\*.MTS'. See http://ant.apache.org/manual/Types/fileset.html for syntax

So, i'm stuck trying to carry some files to the workspace directory in order to be processed there.

Note: I'm using a declarative pipeline for my job.

3 Answers 3

10

In fact, seems that the problem is not copying files from outside the workspace but from outside the current working dir. I still don't know how to do this.

But, you can change the current working dir to be the one that contains files you want to copy, so:

dir("H:\\home\\Videos\\videos") {
    fileOperations([fileCopyOperation(excludes: '', flattenFiles: true, includes: '*.MTS', targetLocation: "${WORKSPACE}")])
}

This code allows you to copy mts files placed in the mentioned directory in the workspace dir. You can see additional help for the dir step here

2
1

When I tried the accepted answer, I stopped getting the error but the file was not copied to my workspace and since there was no error, I got no information as to why.

Anyway what worked for me was to just run a 'powershell' step and use the command 'copy' since I'm working on Windows, and if you are in Linux you can use the step 'sh' instead.

e.g.

powershell 'copy "${source}" ${filename}'
0

you can copy all data manually you can find the data in the Jenkins workspace is in .Jenkins folder then you can copy data from there

then you can copy data throw scripts you can add the power shall plugin and add the build step in the Jenkins job select power shall option

Copy-Item -Path “(source patch)*” -Destination "(destination path)" -Recurse -Force

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.