-
Bug
-
Resolution: Cannot Reproduce
-
Major
-
None
-
Jenkins 2.166
Kubernetes Plugin 1.14.8
Credentials Binding Plugin 1.18
When running via declarative pipeline, any variables bound via Credentials Binding plugin are empty and cannot be used on the running pod. The environment variable should be set via the `withCredentials` but never does.
pipeline { agent { label 'my-pod-label-from-config' } stages { ... stage('Run Playbook') { steps { script { withCredentials([string(credentialsId: "k8s-token-credential", variable: 'K8S_AUTH_API_KEY')]) { sh "printenv" // K8S_AUTH_API_KEY env var is completely missing ... ansiblePlaybook playbook: "playbooks/something.yml", extraVars: ... // the k8s Ansible module relies on K8S_AUTH_API_KEY being set and fails due to 401 UNAUTHORIZED
I've seen a number of PRs opened to address other environment variables set by Jenkins itself (ie. COMMIT_ID and other SCM related vars). However, no combination of withCredentials seems to work when running inside a pod.