K8s pod inheritance not working with k8s secret

10/28/2021

I am trying to read the k8s secret with the Pod template inheritance method.

podTemplate(inheritFrom: 'docker',
        containers: [
        containerTemplate(
        
        envVars: [
            secretEnvVar(key: 'TOKEN', secretName: 'foo', secretKey: 'bar')
        ])
    ]
){
    node('docker') {
        stage('test'){
            sh "echo ${TOKEN}"
        }
    }
}  

but when I run the above code in the pipeline I'm getting this error.

Caused: java.lang.IllegalArgumentException: Could not instantiate {envVars=[@secretEnvVar(key=TOKEN,secretName=foo,secretKey=bar)]} for org.csanchez.jenkins.plugins.kubernetes.ContainerTemplate

can someone help me with this, please?

I'm following this document( pod template inherit section).

-- Jwary
jenkins-pipeline
jenkins-plugins
kubernetes

0 Answers