Jenkins kubernetes plugin not passing environment variables with Pipeline -


jenkins ver. 2.60.1 (running in container on kubernetes)

kubernetes plugin ver. 0.11 (https://github.com/jenkinsci/kubernetes-plugin)

pipeline test:

podtemplate(   label: 'mypod',   volumes: [     persistentvolumeclaim(claimname: 'nfs-maven', mountpath: '/mnt/', readonly: false)],     envvars: [       containerenvvar(key: 'foo', value: 'bar'),     ],   containers: [     containertemplate(name: 'golang',     image: 'golang',      ttyenabled: true,      command: 'cat',      )] ) {   node('mypod') {     stage('test env') {          container('golang') {             stage('build') {                 sh 'echo $foo'                 sh 'sleep 3600'             }         }     }   } } 

the vars not passed containers. echo echoes nothing. echo $foo or echo \$foo have tried on pod level , container level.

when describe created pod following environment vars:

environment:                                                                                                                                  jenkins_location_url:     http://ldn1-kube1:31000/                                                                                          jenkins_secret:           107cb696a8792f998fd41b6ccacf833ea74941fc9a95c39c4b2a1cde4c008b35                                                  jenkins_jnlp_url:         http://10.233.60.248:8080/computer/kubernetes-57beb710bfb44cea8f964d63049b2942-355760c790d6b/slave-agent.jnlp     jenkins_tunnel:           10.233.60.248:50000                                                                                               jenkins_name:             kubernetes-57beb710bfb44cea8f964d63049b2942-355760c790d6b                                                         jenkins_url:              http://10.233.60.248:8080                                                                                         home:                     /home/jenkins                                                                                                   

i'm guessing little, don't think envvars in podtemplate functional. you, haven't had luck podtemplate, i've had no problem using envvars @ containertemplate level. easy fix add envvars there instead.

podtemplate(   label: 'mypod',   volumes: [     persistentvolumeclaim(claimname: 'nfs-maven', mountpath: '/mnt/', readonly: false)],   containers: [     containertemplate(       name: 'golang',       image: 'golang',       ttyenabled: true,        command: 'cat',       envvars: [containerenvvar(key: 'foo', value: 'bar')]     )   ] ) {   node('mypod') {     stage('test env') {          container('golang') {             stage('build') {                 sh 'echo $foo'                 sh 'sleep 3600'             }         }     }   } } 

Comments

Popular posts from this blog

php - Vagrant up error - Uncaught Reflection Exception: Class DOMDocument does not exist -

vue.js - Create hooks for automated testing -

Add new key value to json node in java -