Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-62737

Kubernetes secret doesn't show up in Jenkins /credentials/ page

XMLWordPrintable

      I have the following secret in Kubernetes cluster:

      ```

      apiVersion: v1
      kind: Secret
      metadata:
          name: mysecret
          namespace: <namespace>
      labels:
          credential.sync.jenkins.openshift.io: 'true'
      type: Opaque
      data:
          username: <username>
          password: <password>

      ```

      I have tried to restart the jenkins pod in my k8s cluster. However, the secret does not show up in the jenkins /credentials/ page.

      According to https://jenkinsci.github.io/kubernetes-credentials-provider-plugin/ I have also tried the following secret label:

      ```

      apiVersion: v1
      kind: Secret
      metadata:
          name: mysecret
          namespace: <namespace>
      labels:
          "jenkins.io/credentials-type": "usernamePassword"
      type: Opaque
      data:
          username: <username>
          password: <password>

      ```

      And accessing it in my jenkins pipeline Jenkinsfile using the following snippet:

      ```

      withCredentials([usernamePassword(credentialsId: 'nexus', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')]) { withCredentials([usernamePassword(credentialsId: 'mysecret', usernameVariable: 'USERNAME', passwordVariable: 'PASSWORD')])

      {        echo PASSWORD           echo USERNAME }

      ```

      result in the following error:

      `ERROR: Could not find credentials entry with ID 'mysecret'`

            Unassigned Unassigned
            khteh Kok How Teh
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated: