Search code examples
windowshudsonsmbnet-usenetwork-shares

Mount SMB-shares from Hudson's job: ERROR 1326


In the building system I use some script that copies files from a network drive to the Hudson's workspace by using SMB. Then performs decompression it and deletes the old files.

net use \\NET_DRIVE\ipc$ /user:admin password
robocopy \\NET_DRIVE\SharedFolder/ C:\Users\user\.hudson\jobs\ais\workspace vendor.7z>nul
net use \\NET_DRIVE\ipc$ /D
cd "C:\Users\user\.hudson\jobs\ais\workspace">nul
rd /s /q "C:\Users\user\.hudson\jobs\ais\workspace\vendor\">nul
7za x vendor.7z>nul
del vendor.7z>nul

When I execute this script from Windows command line, everything works and I get my archive. But when I use it in the pipeline, I get error 1326:

Logon failure: unknown user name or bad password

I added the remote domain to the script so that the Windows had not invoked a local account, but it didn't help. I decided to run the command which mount network drive "manually":

net use \\NET_DRIVE\ipc$ /user:admin password /persistent:yes

Then the script a little bit reduced and became working:

robocopy \\NET_DRIVE\SharedFolder/ C:\Users\user\.hudson\jobs\ais\workspace vendor.7z>nul
rd /s /q "C:\Users\user\.hudson\jobs\ais\workspace\vendor\">nul
7za x vendor.7z>nul
del vendor.7z>nul

But I would like to be able to mount SMB-shares from the Hudson's job. How to do it?


Solution

  • Hudson's/ Jenkin's service or servlet- container where it deployed should be run with administrator's privileges.