-
Bug
-
Resolution: Duplicate
-
Critical
Jenkins version: 2.6 - 2.9
Host: Debian 8, Linux 63 bit machine, running in VM. ( jenkins installed through system repos and then updated.)
Project type: Multi configuration project.
Plugins:
a) Build With Parameters: version 1.3
b) Environment Injector Plugin: version 1.92.1
c) Groovy: 1.29
Problem: The parameterized build variables are not are not visible (as env variables) in the Execution step "shell script", They used to be visible in the older 1.x jenkins version.
EDIT[2016-22-june]: THESE PARAMETERS ARE VISIBLE AS ENV VARIABLES ON MASTER BUT NOT ON THE SLAVES.
Steps:
Create a parameterized build with a multi configuration project.
Add a parameter to the build (using This project is parameterized-> string parameter,
).
Add a build step "Execute shell" to the job.
Access these parameters in this shell script as env variables.
echo "++++++++++++ building $lib_name ($lib_version) ++++++++++++++"
Workaround--> for the time being, I have tried to create a groovy script in "Prepare an environment for the run" section. I created env variables using hardcoded values which are pased to shell script as env vars.
def map = ['lib_name':'lib1']
map['lib_version'] = 'master'
return map
This makes these "Hardcoded" variables visible in jenkins shell script..
+++++++++++++++++++++++++++++++++++++++++++++++++++++++
EDIT: 23-july-2016: (tested with adding section "Prepare an environment for the run"
Logs from Master.
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - Executing and processing the following script content:
export BRANCH_NAME=${BRANCH_NAME}
export BUILD_STAGE=${BUILD_STAGE}
[****] $ /bin/bash -xe /tmp/hudson803008212850989562.sh
+ export BRANCH_NAME=feature/ABC
+ BRANCH_NAME=feature/ABC
+ export BUILD_STAGE=STAGE1
+ BUILD_STAGE=STAGE1
++++++++++++++++++++++++++++++++++++++++++++++++
Logs from SLAVE.
[EnvInject] - Inject global passwords.
[EnvInject] - Mask passwords passed as build parameters.
Gestartet durch vorgelagertes Projekt "COMPACT2", Build 1
originally caused by:
Gestartet durch Benutzer ABC DEF GHI
[EnvInject] - Loading node environment variables.
[EnvInject] - Preparing an environment for the build.
[EnvInject] - Keeping Jenkins system variables.
[EnvInject] - Keeping Jenkins build variables.
[EnvInject] - Executing and processing the following script content:
export BRANCH_NAME=${BRANCH_NAME}
export BUILD_STAGE=${BUILD_STAGE}
[****] $ /bin/bash -xe /tmp/hudson7212379337542594663.sh
+ export BRANCH_NAME=
+ BRANCH_NAME=
+ export BUILD_STAGE=
+ BUILD_STAGE=
[EnvInject] - Script executed successfully.
[EnvInject] - Injecting contributions.
- blocks
-
JENKINS-35024 Parametrized build doesn't set environment variables in Mutli-configuration projects
- Resolved