Question

I have an ant file which has move and copy tasks. The source and destination locations are on the mapped network drive R:\. When I run them on the command prompt the build is successful but when I configure it as a job in Jenkins, the tasks are failing with the below console output.

BUILD FAILED
C:\Users\admin\.jenkins\jobs\CopyTask\workspace\build.xml:24: R:\dest does not exist.

Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE

Both the standalone build and Jenkins build are under the same user credentials.

I have looked in the the questions copy in ANT throws java.io.FileNotFoundException and Ant Copy Task: Failed to copy due to java.io.FileNotFoundException but it didn't help me solve the issue.

EDIT

Jenkins service was running under local system account and in Jenkins app, I was using "Jenkins's own user database" for Security Realm. I had created a user called "admin" with all the permissions granted. After looking in to this link, I installed Active Directory Plugin and used an administrator account credentials to start the Jenkins service. But still I am getting the below error message

BUILD FAILED
C:\Users\admin\.jenkins\workspace\CopyTask\build.xml:11: 
Failed to copy C:\Users\admin\FldrToCopy\data.7z to 
R:\data.7z due to failed to create the parent directory for R:\data.7z

Total time: 0 seconds
Build step 'Invoke Ant' marked build as failure
Finished: FAILURE
Was it helpful?

Solution

Obviously, the system account you're using doesn't have this mapped drive. Before copying, try to map the drive through the Windows net use command. In Jenkins, you can run this in your build steps as a shell command before you execute your Ant script.

I don't have a Windows machine in front of me, but it should look something like this:

net use R: /delete
net use R: /persistent:yes \\windows\share\path

You want to do the net use R: /delete first to remove any already existing mapping.

If this doesn't work, try this. This will help you create a mapped drive to your system account that always exist.

OTHER TIPS

What user account is Jenkins running as? If it's running as the SYSTEM account, then it probably can't see the mapped drive. Take a look at Map a network drive to be used by a service for some ideas.

Or perhaps you could use the UNC path instead of the mapped drive?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top