2016-09-12 12 views
5

tôi vượt qua trong thông tin để kịch bản thông qua env phun (lưu ý làm việc này cho tôi với Invoke-Command) và cố gắng chạy Start-Job nhưng Jenkins không thích nó:Jenkins sẽ không chạy Start-Job với tham số Credential

$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 

Đây là lỗi tôi nhận được (tên đăng nhập và mật khẩu xác nhận là chính xác, khi tôi chạy kịch bản này từ giao diện điều khiển với creds cùng nó hoạt động)

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 

Trả lời

0

tôi đã có vấn đề với các thông tin vào những thời điểm với PowerShell, tôi có thể bình thường ly sửa lỗi bằng cách sử dụng tính năng này:

$username = Username 
$password = Password 

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

Nhập thông tin xác thực vào thông tin xác thực, sau đó sử dụng thông tin đăng nhập đó để xác thực.

Các vấn đề liên quan