admin管理员组文章数量:1391975
I'm new to Jenkins (version 2.492.2 on Windows) and cannot seem to get access to the password from withCredentials
via the shell/environment variable.
I’ve tried a few variations in the snippet below. From everything I see, my environment/shell variable (at the process level) is being set to “*** Not Valid For Display ***”, so no matter how I access it from with the script, the actual password isn’t there.
Though this snippet doesn't show it, my goal is to pass the password to Powershell function within the pwsh{} block.
pipeline {
agent any
stages {
stage('Cred Test') {
steps {
withCredentials([usernamePassword(credentialsId: 'xxxx', passwordVariable: 'impersonation_userpw', usernameVariable: 'impersonation_username')]) {
pwsh(returnStdout: true, script: '''
$pw = $env:impersonation_userpw
Write-Warning "# $pw"
Write-Host $(Get-ChildItem Env: | %{
$len = [Math]::Min(10,$_.Value.Length)
"{0}`t{1}....`r`n" -f $_.Name,$_.Value.substring(0,$len)}
)
The variable dump in that script emits:
HUDSON_HOME C:\data\Je....
HUDSON_SERVER_COOKIE 015d679e37....
HUDSON_URL http://loc....
impersonation_username svc-se......
impersonation_userpw *** Not Va....
JAVA_HOME C:\Program....
JENKINS_HOME C:\data\Je....
JENKINS_NODE_COOKIE 4573f16f-0....
JENKINS_SERVER_COOKIE durable-bf....
JENKINS_URL http://loc....
JOB_BASE_NAME Pipeline D....
本文标签: withCredentials Credential Variable Injection and Interpolation in Jenkins on WindowsStack Overflow
版权声明:本文标题:withCredentials Credential Variable Injection and Interpolation in Jenkins on Windows - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744750885a2623167.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论