jenkinsci / jenkinsci/credentials-binding-plugin
[JENKINS-62737] Kubernetes secret doesn't show up in Jenkins /credentials/ page
- 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
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
Assessment
This issue has not been assessed yet.