似乎无法弄清楚这一点,当我在管道中运行以下步骤时,变量似乎为空:
steps {
withCredentials([certificate(credentialsId: 'pfxCert', keystoreVariable: 'pfxPath', passwordVariable: 'pfxPassword')]) {
powershell '''
$keyContainerName = "somekey123"
$cert = New-Object System.Security.Cryptography.X509Certificates.X509Certificate2
$cert.Import($pfxPath, $pfxPassword, [System.Security.Cryptography.X509Certificates.X509KeyStorageFlags]::Exportable)
$exportPrivateKeyInformation = $true
$certXml = $cert.PrivateKey.ToXmlString($exportPrivateKeyInformation)
$csp = New-Object System.Security.Cryptography.CspParameters
$csp.KeyContainerName = $keyContainerName
$csp.Flags = [System.Security.Cryptography.CspProviderFlags]::UseMachineKeyStore -bor [System.Security.Cryptography.CspProviderFlags]::NoPrompt # -bor is biwise or
$csp.KeyNumber = [System.Security.Cryptography.KeyNumber]::Signature
$rsa = New-Object System.Security.Cryptography.RSACryptoServiceProvider $csp
$rsa.FromXmlString($certXml)
$rsa.Clear()
'''
}
以下是错误输出:
powershell.exe : Exception calling "Import" with "3" argument(s): "Array may not be empty or null.
我还可以使用秘密文本凭据进行下一步,但是它使用bat而不是powershell。有人知道我在做什么错吗?预先感谢。