2016-09-12 11 views
5

Kimlik parametresi ile Başlat-Job çalıştırmak ve Start-Job çalıştırmayı denediğinizde ancak Jenkins bunu sevmez olmaz:Jenkins I (bu <code>Invoke-Command</code> ile benim için çalışıyor dikkat edin) <code>env</code> enjektör vasıtasıyla komut dosyasına kimlik geçmek

Bu

$user = $ENV:user 
$pass = $ENV:pass 

write-output (cat env:username) 
write-output (cat env:user) 
write-output (cat env:pass) 

$pass = $pass | ConvertTo-SecureString -AsPlainText -Force 
$cred = New-Object System.Management.Automation.PSCredential -ArgumentList ($user), $pass 

Start-Job -Credential $cred -ScriptBlock {'test'} 

write-output (get-job | Receive-Job) 
get-job | remove-job 
I (teyit kullanıcı adı ve şifre aynı creds ile konsoldan bu komut dosyasını çalıştırdığınızda çalıştığını, doğru)

Started by user ME 

[EnvInject] - Loading node environment variables. 
Building in workspace C:\Program Files (x86)\Jenkins\jobs\myjob\workspace 
[workspace] $ powershell.exe -NonInteractive -ExecutionPolicy ByPass "& 'C:\Windows\TEMP\hudson1723222179976241861.ps1'" 
MYJENKINSSRV$ 
correctdomain\correctuser 
correctPassword 

Id  Name   PSJobTypeName State   HasMoreData  Location 
--  ----   ------------- -----   -----------  -------- 
1  Job1   BackgroundJob Failed  False   localhost 
[localhost] An error occurred while starting the background process. Error 
reported: Access is denied. 
    + CategoryInfo   : OpenError: (localhost:String) [], PSRemotingTran 
    sportException 
    + FullyQualifiedErrorId : -2147467259,PSSessionStateBroken 


Finished: SUCCESS 

cevap

0

i ile zaman zaman kimlik bilgileriyle sorunları yaşadım olsun hatadır PowerShell, her zamanki gibi ly bu kullanarak bunu düzeltmek:

$username = Username 
$password = Password 

$cred = New-Object -TypeName System.Management.Automation.PSCredential ($username, $password) 
$Credentials = Get-Credential $cred 

Temelde sonra kimlik bilgileri bu kullanarak, Al-kimlik haline kimlik bilgilerinizi girerek.

İlgili konular