RogerG Posted July 4, 2018 Report Posted July 4, 2018 Hi list, I am trying to use this script to copy a file from one directory to another def publish() { echo "Publish artifacts ..." String sourceFilePath = "%WORKSPACE%\\app\\build\\outputs\\newrelease.tar" String destinationFilePath = "\\app.xxx.net\\d\$\\Share" // bat 'copy ${sourceFilePath} ${destinationFilePath}' (new AntBuilder()).copy(file: sourceFilePath, tofile: destinationFilePath) } I am getting the following error even after approving from "in process script approvals" : org.jenkinsci.plugins.scriptsecurity.sandbox.RejectedAccessException: Scripts not permitted to use new groovy.util.AntBuilder at org.jenkinsci.plugins.scriptsecurity.sandbox.whitelists.StaticWhitelist.rejectNew(StaticWhitelist.java:184) at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onNewInstance(SandboxInterceptor.java:148) def pipeline () { buildStage() pubish() } If I use bat 'copy ${sourceFilePath} ${destinationFilePath}' I am getting following error: org.jenkinsci.plugins.workflow.steps.MissingContextVariableException: Required context class hudson.FilePath is missing Thanks in advance Quote
RogerG Posted July 5, 2018 Author Report Posted July 5, 2018 I have figured out that actually, I was not using that properly in the Pipeline. I am stuck with another problem, copying files from Workspace on Windows def deployartifact() { echo "Deploy artifacts ..." stage('Deploy') { node { def sourceFilePath = 'outputs\\release\\file.tar' def destinationFilePath = '\\\\server.net\\d\$\\Share' echo "Sourcefilepath is ${sourceFilePath} and Destinationpath is ${destinationFilePath}" bat 'copy %WORKSPACE%\\${sourceFilePath} ${destinationFilePath}' } } } File is not getting copied because of the WORKSPACE, I tried env.WORKSPACE also. Thanks in advance Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.