jenkinsci / jenkinsci/credentials-binding-plugin

[JENKINS-62737] Kubernetes secret doesn't show up in Jenkins /credentials/ page

Open
#482 3 comments 0 reactions 0 assignees View on GitHub
component:credentials-binding-plugin imported-jira-issue priority:blocker resolution:unresolved
Dominant language
Java
Stars
57
Forks
108
PR merge metrics
No merged PRs in 30d

Description

I have the following secret in Kubernetes cluster:

```

apiVersion: v1

kind: Secret

metadata:

    name: mysecret

    namespace:

labels:

    credential.sync.jenkins.openshift.io: 'true'

type: Opaque

data:

    username:

    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:

labels:

    "jenkins.io/credentials-type": "usernamePassword"

type: Opaque

data:

    username:

    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'`

---
Originally reported by khteh, imported from: Kubernetes secret doesn't show up in Jenkins /credentials/ page


  • status: Open
  • priority: Blocker
  • component(s): credentials-binding-plugin
  • label(s): credentials-binding
  • resolution: Unresolved
  • votes: 0
  • watchers: 3
  • imported: 20251211-141027

Raw content of original issue

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'`

  • environment: Kubernetes

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.