2014-02-28 35 views
0

我開發了一個powershell腳本,它接受buncha參數,創建MSDeploy字符串並執行它。我測試過此PowerShell命令:使用powershell的teamcity和msdeploy

  1. 它工作在我的本地盒(安裝來自我的本地框web應用程序 遠程IIS服務器)
  2. 它的工作原理上的TeamCity盒(安裝Web 從球隊城市的文件夾結構,以遠程IIS服務器)應用

問題:

,當我從TeamCity的瀏覽器VERSI運行命令它不工作上。

的錯誤是:ERROR_USER_NOT_ADMIN

請注意,我的TeamCity建立代理既是我的TeamCity服務器上的本地管理員和IIS遠程服務器

Powreshell源代碼:

$msDeploy = 'C:\Program Files (x86)\IIS\Microsoft Web Deploy V3\msdeploy.exe' 
$sourcePackage = $args[0] 
$paramFile = $args[1] 
$iisAppPath = $args[2] 
$servername = $args[3] 
$usreName = $args[4] 
$password = $args[5] 
$includeAcls = $args[6] 

function UpdateParamFile($paramXMLFile, $applicationPath) 
{ 
    $doc = New-Object System.Xml.XmlDocument 
    $doc.Load($paramXMLFile) 

    #IIS Application Path (this is where the code will be deployed - it has to exist in target IIS): 
    $appPath = $doc.SelectSingleNode("//parameters//setParameter[@name = 'IIS Web Application Name']") 
    $appPath.value = $applicationPath 

    #Connection Strings: 

    #KDB Connection string: 

    #Save 
    $doc.Save($paramXMLFile) 

    #[xml] $xmlPars = Get-Content $paramXMLFile 
    #$xmlPars.parameters.setParameter | Where-Object { $_.name -eq 'IIS Web Application Name' } | select value 
} 

UpdateParamFile $paramFile $iisAppPath 
$arguments = "-source:package=$sourcePackage", "-dest:auto,computerName=`"$servername`",userName=`"$usreName`",password=`"$password`",includeAcls=`"$includeAcls`"", "-setParamFile:$paramFile", '-verb:sync', '-disableLink:AppPoolExtension', '-disableLink:CertificateExtension', '-disableLink:ContentExtension' 
&$msDeploy $arguments 

Teamcity調用上述腳本文件:

C:\ Windows \ System32 \ WindowsPowerShell \ v1.0 \ powershell.exe -NonInteractive -ExecutionPolicy ByPass -File C:\ TeamCity \ buildAgent \ work \ 253e6183c0596123 \ Debug \ PMRSWebsite \ DeployWeb.ps1 Debug \ PMRSWebsite \ Web。 csproj.zip「Debug \ PMRSWebsite \ Web.csproj.SetParameters.xml」^^^ IIS_APP_NAME ^^^ ^^^ ServerName ^^^ ^^^ userName ^^^ ^^^密碼^^^ false

回答

2
ERROR_USER_NOT_ADMIN 

Diagnosis - This happens if you try to connect to the Remote Agent Service but 
    have not provided appropriate administrator credentials. 

Resolution - The Remote Agent Service accepts either built-in Administrator or 
    Domain Administrator credentials. If you have a non-domain setup and want to 
    use account other that built-in administrator, please do following: 

    1. Create a separate user group MSDepSvcUsers on remote computer. 
    2. Create an local account A on both local & remote computer. 
    3. Add A to MSDepSvcUsers on remote computer. 
    4. Use account A to publish, this will allow you to publish without needing to 
    use built-in admin account. 

via

+0

不,這不會/不是解決所述問題的方法。我使用的帳戶實際上是兩個盒子上的本地管理員;正如我前面提到的,我能夠運行msdeploy沒有問題;但是,從Teamcity執行時完全相同的msdeploy代碼會導致ERROR_USER_NOT_ADMIN錯誤。 Teamcity的構建代理也運行在兩個框均爲本地管理員的帳戶下,也在Domain Admin中運行。清楚的是,我運行命令行中的TeamCity框中的msdeploy代碼。這是Teamcity的瀏覽器版本提供的錯誤。我認爲管理員錯誤是一個紅鯡魚 – DotNet98

+0

你試過這裏介紹的解決方案嗎? –

+0

是的,我做到了。關於「帳戶」,我們是在討論msdeploy的-dest參數中指定的帳戶,還是我們正在討論調用msdeploy的帳戶(即teamcity構建代理服務帳戶)?感謝您跟隨這與我順便說一句:) – DotNet98