【发布时间】:2015-01-10 23:24:14
【问题描述】:
我有一个运行部署脚本的章鱼触手。触手作为 LocalSystem 帐户运行。
在脚本中,除了一些存档位之外,我几乎可以做所有我需要的事情。归档需要在不同的域凭据下完成,因为它位于网络共享上。
令人沮丧的是,下面的代码在本地工作,但是当脱离触手时,它会失败并出现错误
----------------------------------- -----[ 备份 Nupkg ]------------------------------------------ ------------ 存储备份 用于开发环境的 GeoSphere.1.2.1.1722.nupkg 版本
错误 09:24:32 [localhost] 启动时出错
后台进程。错误 09:24:32 报告错误:访问是
否认。错误 09:24:32 在
C:\Octopus\Deployments\Development\GeoSphere\1.2.1.1722\deploy.ps1:121
错误 09:24:32 字符:1 错误 09:24:32
+ 接收作业 $job 错误 09:24:32
+ ~~~~~~~~~~~~~~~~ 错误 09:24:32
+ CategoryInfo : OpenError: (localhost:String) [], PSRemotingTran 错误 09:24:32 sportException 错误 09:24:32
+ FullyQualifiedErrorId:-2147467259,PSSessionStateBroken 信息 09:24:32 HasMoreData:错误 StatusMessage:位置:
本地主机命令: 导入模块 $args[3]
备份 Nupkg $args[0] $args[1] $args[2]
JobStateInfo:失败完成:System.Threading.ManualResetEvent InstanceId:
0c031592-4c2a-4f8b-b014-a5ba79be09f7 标识:1 名称:
Job1 ChildJobs : {Job2} PSBeginTime : 13/11/2014 9:24:30 AM
PSEndTime:2014 年 13 月 11 日上午 9:24:31 PSJobTypeName:BackgroundJob
输出:{} 错误:{} 进度:{} 详细
:{}调试:{}警告:{}状态:失败
致命 09:24:32 PowerShell 脚本返回非零退出代码:1
触手版 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
让这个像在本地一样从触手上跑掉的魔术是什么?
【问题讨论】:
-
另外,我尝试让 Tentacle 服务以指定用户身份运行,但随后我遇到了一个 IIS 配置问题,这导致了另一个问题。这些有效的身份验证问题很痛苦。
标签: powershell credentials octopus-deploy