Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Get Perforce credential info (other than username and password) in Jenkins Pipeline script

50 views
Skip to first unread message

Wu Ingrid

unread,
May 7, 2020, 7:03:42 PM5/7/20
to Jenkins Pipeline Authoring SIG

Hello,


I have a Jenkins Pipeline that has been using a Global Perforce Password Credential to perform several P4 commands. Up till now, I need to use and extract the user and password from this credential, which has been straightforward enough:

environment {
    P4_CREDS = credentials('jenkins-p4-creds')
}
stages{
    stage("Process Perforce Workspace"){
        steps {
            script {
                bat("MyP4Cmd.bat ${P4_CREDS_USR} ${P4_CREDS_PSW}")
            }
        }
    }
}

Recently, though, I find myself needing the Perforce server port as well (the field "P4Port"). Given a known P4 credential, how do I obtain the server port from it in the Pipeline?


Thank you and stay well,

Ingrid

Reply all
Reply to author
Forward
0 new messages