我正在使用环境凭据获取用户名和密码。当我输出它们时,它们被打印为
接下来是PowerShell命令,当我单独运行它们时,所有命令都可以正常工作。但是通过Jenkins管道运行时,会抛出以下错误:
****
。接下来是PowerShell命令,当我单独运行它们时,所有命令都可以正常工作。但是通过Jenkins管道运行时,会抛出以下错误:
有人能解释一下这是否是在Jenkins管道中整合PowerShell的正确方式吗?groovy.lang.MissingPropertyException: No such property: psw for class: groovy.lang.Binding
environment {
CREDENTIAL = credentials('Test')
}
stage('Deployment') {
steps {
echo "$CREDENTIAL_USR"
echo "$CREDENTIAL_PSW"
powershell """($psw = ConvertTo-SecureString -String $CREDENTIAL_PSW -AsPlainText -Force)"""
powershell """($mySecureCreds = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $CREDENTIAL_USR, $psw -Verbose)"""
powershell """(Set-Item WSMan:/localhost/Client/TrustedHosts -Value "*" -Force)"""
powershell """($session = New-PSSession -ComputerName "192.111.111.111" -Credential $mySecureCreds)"""