I have created a jenkins file that above everything else that is does, in the end will copy paste a .jar file from the jenkins target directory to home directory. I tried many options like sudo cp and sudo visudo to give jenkins privilleges but that didn't work, besides it's not safe from security perspective.
Then I tried to install the FileOperations plugin.
stage("Copy the created .jar file to home directory for docker deployment"){
steps{
fileOperations([fileCopyOperation(
flattenFiles: false,
includes: '*.jar',
targetLocation: "home/user"
)])
}
}
Output:
18:27:37 File Copy Operation:
18:27:37 /var/lib/jenkins/workspace/pipeline_production/my.jar
18:27:37 FATAL: /home/user/my.jar
I quite miss what is going wrong with this configuration and does no succeed. Appreciate any suggestion.
Similar question here