mi przepustkę mandatów do skryptu poprzez env
wtryskiwacza (uwaga ta działa na mnie z Invoke-Command
) i spróbuj uruchomić Start-Job
ale Jenkins nie podoba:Jenkins nie będzie działał Start-Job z poświadczeń parametru
$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
jest to błąd pojawia się (potwierdzone nazwa użytkownika i hasło są poprawne, kiedy uruchomić ten skrypt z konsoli z tymi samymi creds to działa)
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