2

I'm using the ArtifactDeployer plugin to deploy the build job artifacts to a remote location (Windows share SMB). However Jenkins never manages to succeed. Throwing errors like:

[ArtifactDeployer] - Starting deployment from the post-action ... [ArtifactDeployer] - [ERROR] - Failed to deploy. Can't create the directory ... Build step [ArtifactDeployer] - Deploy artifacts from workspace to remote directories' changed build result to FAILURE

Local deployment works fine.

The Jenkins machine OS is Windows 7 32-bit Prof. Jenkins is running as a service using a local system account.

I tried using another account, my user account but the service failed to start (Windows error 1069: the service did not start due to a logon failure). The network service account did run but than Jenkins throws errors it can't access the .NET framework.

When manually trying the remote copy, this works fine. I can create directories and write to it. On the same machine of course.

I tried two different remote reference in Jenkins: 1) \\targetdirectory 2) I:\ - by mapping a drive letter to the remote dir in windows No success...

Any tips or suggestions? Thanks!

Update 15/02/2012: Still no solution or workaround for this issue. It's not only the plugin, I hit also this issue using "Execute Windows batch command". I found a bug report that I want to share.

Solution

I found a solution. You have to grant access persmission to the computer in a domain instead of the user of that machine. Seems very logic if you look back to it.

A 2nd solution is to run the service using a domain user account. Above I made a mistake by using the local user .\user in stead of DOMAIN\user.

Community
  • 1
  • 1
Nick V
  • 1,593
  • 2
  • 16
  • 19

2 Answers2

1

If you don't have a domain, the following will work for sure. This should work even if you have a domain.

Background Info:
You need your mapped drive to be mapped for the same account that the service is using AND be available at the right time. Normally mapped drives are mapped only for the logged in user, at the time that they log in. Service user contexts don't get "logged in" per se -- for example, if I map a drive as MyUser and the service runs as MyUser, the drive won't be available until I actually log in by typing in my password. However, we can use a script to map the drive at startup (instead of login) for a particular user. Jenkins normally runs as Local System Account, so if you don't want to change that, you'll need to run the script below as the SYSTEM user. You can instead create a specific user for Jenkins to run as, if you don't want to grant this mapped drive to all services/processes that run as SYSTEM, and run both the service and the script below as that user (this is probably more secure).

Solution Steps:
In ArtifactDeployer you want to deploy to a mapped network drive. In my case this is S:.

There is no special setup for permissions on the remote share. (In my case, a Windows Server 2008 share with a username and password that is used for mapping the drive.)

Write a batch file MapDrives.bat in a place that your chosen user (default: SYSTEM) has access to, with the following in it:

net use S: "\\server_name\share_name" /persistent:yes password_here /USER:username_here

Note that I am mapping to S: in that line.

Via Task Scheduler, create a task that runs as the same user as the service (default: SYSTEM), triggers At Startup, and as it's action, runs the batch file MapDrives.bat.

Reboot and it should work!


Citations:
After diving through many pages and many tests, ultimately, the best suggestions were found here, and led me to the above solution.
https://stackoverflow.com/a/4763324/150794

Community
  • 1
  • 1
Mark Ribau
  • 1,539
  • 1
  • 14
  • 20
0

Make sure your 'local system account' has access rights to the remote directory (including write access). Then use the notation

\\targetdirectory

Mapping drive letters to remote directories only applies to the user account you are currently working with. The drive letter mapping will not be available to any other account.

Frank Kusters
  • 2,312
  • 2
  • 19
  • 27
  • It would be better to ask a seperate question for that on http://superuser.com/ . (And post a link to the question here.) – Frank Kusters Nov 02 '12 at 10:41