我有一個運行部署腳本的Octopus Tentacle。觸手以LocalSystem帳戶運行。使用Octopus Deploy中備用憑據的PowerShell作業
在腳本里面,除了一些存檔位之外,我幾乎可以做任何我需要的東西。檔案需要在不同的域憑證下完成,因爲它在網絡共享上。
令人沮喪的這是下面的代碼本地工作,但在逃跑的觸角,它失敗,出現錯誤
----------------------------------------------------[ Backup Nupkg ]---------------------------------------------------- Storing a backup version of GeoSphere.1.2.1.1722.nupkg for the Development environment
Error 09:24:32 [localhost] There is an error launching the
background process. Error Error 09:24:32 reported: Access is
denied. Error 09:24:32 At
C:\Octopus\Deployments\Development\GeoSphere\1.2.1.1722\deploy.ps1:121
Error 09:24:32 char:1 Error 09:24:32
+ Receive-Job $job Error 09:24:32
+ ~~~~~~~~~~~~~~~~ Error 09:24:32
+ CategoryInfo : OpenError: (localhost:String) [], PSRemotingTran Error 09:24:32 sportException Error 09:24:32
+ FullyQualifiedErrorId : -2147467259,PSSessionStateBroken Info 09:24:32 HasMoreData : False StatusMessage : Location :
localhost Command : Import-Module $args[3]
Backup-Nupkg $args[0] $args[1] $args[2]
JobStateInfo : Failed Finished : System.Threading.ManualResetEvent InstanceId :
0c031592-4c2a-4f8b-b014-a5ba79be09f7 Id : 1 Name :
Job1 ChildJobs : {Job2} PSBeginTime : 13/11/2014 9:24:30 AM
PSEndTime : 13/11/2014 9:24:31 AM PSJobTypeName : BackgroundJob
Output : {} Error : {} Progress : {} Verbose
: {} Debug : {} Warning : {} State : Failed
Fatal 09:24:32 PowerShell script returned a non-zero exit code: 1
Tentacle version 2.5.11.614
下面的代碼
$pwd = convertto-securestring "[PASSWORD]" -asplaintext -force
$cred=new-object -typename System.Management.Automation.PSCredential -argumentlist "[DOMAIN\USER]",$pwd
$packageName = "GeoSphere.$Version.nupkg"
$backupPath = $($es.backupPath)
$artifactsPath = $($es.artifactsPath)
$job = Start-Job -ScriptBlock {
Import-Module $args[3]
Backup-Nupkg $args[0] $args[1] $args[2]
} -ArgumentList @($packageName,$backupPath,$artifactsPath,"$currentDir\modules\ApplicationUtilities") -Credential $cred
Wait-Job $Job
Receive-Job $job
這裏的ApplicationUtilities
模塊
function Backup-Nupkg{
param(
[parameter(Mandatory=$true,position=0)] [string] $packageName,
[parameter(Mandatory=$true,position=1)] [string] $backupPath,
[parameter(Mandatory=$true,position=2)] [string] $artifactsPath
)
if(!(Test-Path $($backupPath))) {
md $($backupPath)
} else {
Remove-Item "$($backupPath)\*" -recurse -Force
}
Copy-Item $artifactsPath\$packageName $backupPath
}
Export-ModuleMember Backup-Nupkg
讓這個跑掉的魔術是什麼?觸手,因爲它在本地?
此外,我試圖讓觸手服務作爲指定用戶運行,但後來我得到一個IIS配置問題,引發另一個扳手混合。這些冒險的認證問題是痛苦的。 –