-
Bug
-
Resolution: Fixed
-
Major
-
None
Environment variables defined within a container step are not available to sh steps, only environment variables defined prior to the container step. So this scenario (for which a testcase already exists) works:
withEnv(['foo=1']) { container('container') { sh 'echo foo=$foo' // prints foo=1 } }
But this one doesn't:
container('container') { withEnv(['foo=1']) { sh 'echo foo=$foo' // prints foo= } }
Nor do other things that would manipulate the environment:
container('container') { env.foo = 1 sh 'echo foo=$foo' // prints foo= }
For example, this also causes problems when using sshagent, as the sh step cannot see the SSH_AUTH_SOCK environment variable:
container('container') { sshagent(['credential-id']) { sh 'ssh-add -l' // fails with message "Could not open a connection to your authentication agent." } }
- causes
-
JENKINS-47210 parameters are not available as environment variables in pod containers
- Closed
- is duplicated by
-
JENKINS-42582 ssh-agent not applied in kubernetes container
- Resolved
-
JENKINS-49110 withSonarQubeEnv in Jenkins pipeline not setting SonarQube env whe using Kubernetes
- Resolved