I run my Jenkins build inside a docker container (node:latest).
But the enviroments variables are not defiend in the container:
$GIT_BRANCH, $GIT_COMMIT
So I got this error:
GitHub has been notified of this commit’s build result
groovy.lang.MissingPropertyException: No such property: GIT_BRANCH for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
I have a lot of variables I need to pass into the container. how to do that with Jenkins?
I looking for solution that inherit all environment variables that exist in Jenkins process and my host machine/docker
Here my Jenkinsfile:
throttle(['throttleDocker']) {
node('docker') {
wrap([$class: 'AnsiColorBuildWrapper']) {
try{
docker.image('node:latest').inside {
stage('Checkout SCM'){
checkout scm
}
stage('PS'){
sh 'node -v'
sh 'ls'
}
stage('Verify Branch') {
echo "$GIT_BRANCH"
echo "$GIT_COMMIT"
}
stage('Build'){
sh "npm run build"
sh 'ls'
}
stage('Test'){
sh 'echo "Test Stage inside container."'
}
}