How to use credentials in User scope stored on Jenkins of OpenShift?

Solution Unverified - Updated -

Issue

  • In a jenkins pipeline, credentials in User scope stored on Jenkins cannot be used directly like this:

    pipeline{
    agent{label 'maven'}
    stages{
    stage('Credential'){
      steps{
        script{
          openshift.withCluster(){
            openshift.withProject(){
              openshift.withCredentials('user-1-credential'){
                echo "${openshift.raw("whoami")}"
    
    // result: err=error: You must be logged in to the server (Unauthorized)
    

Environment

  • Red Hat OpenShift Container Platform
  • Jenkins

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content