-
Bug
-
Resolution: Fixed
-
Major
-
None
The environment declarative no longer works in pipeline.
pipeline { agent { kubernetes { label 'maven-pod' containerTemplate { name 'maven-container' image 'maven' workingDir '/home/jenkins' ttyEnabled true command 'cat' } } } environment { test = 'Hello World!' } stages { stage('print') { steps { //will not print sh 'echo ${test}' container('maven-container'){ //will also not print sh 'echo ${test}' } } } } }
It appears to be due to environment variables for the container being set prior to container execution.
- is related to
-
JENKINS-40647 With Env not working after .10 k8 plugin update
-
- Resolved
-
-
JENKINS-46670 Wrong escaping of environment variables in container Step
-
- Resolved
-
I've identified a code work around for part of this in the attached patch.
EDIT: patch that can be applied on current master (64a6717)
0001-Added-envvars-to-fix-missing-environment-variables-d.patch
This allows the container step to work properly but not the default container context to work(the first sh command).
I'd be happy to work and fix this in another way if preferred - just point me in the direction where environment variables are currently merged into the container execution scope.