Search code examples
jenkinsgradlecopynetwork-drive

Gradle copy file task fails to copy to mapped network drive via Jenkins


I am using Jenkins and running Gradle tasks to build a jar, executable and a setup.exe file. One of my gradle tasks is to copy the built setup.exe file to mapped network drive on the agent in runs on. I am trying to copy the setup file to a folder on the mapped drive called 2.x. I get the error: "Cannot convert URL 'z:/Developers/Projects/builds/v2.x/' to a file."

task copySetup(type: Copy) {
from file("${projectDir}/Setup.exe")
into file ("z:/Developers/Projects/builds/v2.x")
}

If I run the task myself in the workspace then it works. Only fails when Jenkins runs it. I use a Gradle wrapper so it shouldn't be a Gradle version issue I think.


Solution

  • So I got my answer from this post by ForcePush: Map a network drive to be used by a service

    Even though Jenkins runs as the user account I used to map the network drive, the service does not see any mapped network drives. The answer by ForcePush solves this problem.