I'm using BITS to transfer file from one windows 2008 R2 server to the other. When I run the command manually from powershell or regular command line it works perfectly. Now when I use the same command as part of a build script in Jenkins it fails with the following error :
Start-BitsTransfer : Cannot find path '\192.168.1.210\C$' because it does not exist.
Jenkins runs as a windows service under "Local System" account. I thought changing the windows service to run under "Network Service" account might help, but that's not the case either.
Is there's some security reason which does not allow BITS to run from a windows service?
Here's the Powershell script I have deploy.ps1:
Function Get-PSCredential($User,$Password)
{
$SecPass = convertto-securestring -asplaintext -string $Password -force
$Creds = new-object System.Management.Automation.PSCredential -argumentlist $User,$SecPass
Return $Creds
}
$credential = Get-PSCredential -User jenkins -Password jenkins
Import-Module BitsTransfer
Start-BitsTransfer -source c:\file.zip -destination \\192.168.1.210\C$\Website -credential $credential
Confirming again, the above powershell script works perfectly fine when i trigger it manually myself using powershell or windows command.
This is the command I use in Jenkins to trigger the script:
Powershell.exe -noprofile -executionpolicy Bypass -file C:\deploy.ps1