-
Improvement
-
Resolution: Fixed
-
Major
-
None
-
Redhat Linux 5.5
I want to set value for an environment variable based on user provided input during the build and use this env variable to set workspace in a jenkins project.
Ex: User has to select MODULE_NAME when performing a build. MODULE_NAME is a choice parameter. Based on the value selected by the user I want to set MODULE_FOLDER environment variable and use it for setting the WORKSPACE.
Below is the functionality I am expecting.
if MODULE_NAME is 'A' then set MODULE_FOLDER = FOLDER1
else if MODULE_NAME is 'B' then set MODULE_FOLDER = FOLDER2
else if MODULE_NAME is 'C' then set MODULE_FOLDER = FOLDER3
Now set WORKSPACE=/usr/modules/$MODULE_FOLDER
Please help me achieve this functionality. I want to have only one job for all modules. Based on the module user selects I want to build it and deploy it.
your guidance is much appreciated
Greg,
I am able to successfully run the groovy script that serves my purpose. I really appreciate your help and time. You are very responsive and quick
Below is the log. MODULE_NAME is provided by user when performing build.
[EnvInject] - Evaluation the following Groovy script content:
if(MODULE_NAME.equals('ACCT'))
{
def map = ["MODULE_HOME": "SSP-AM"]
return map;
}
if(MODULE_NAME.equals('FPD'))
{
def map = ["MODULE_HOME": "SSP-FPD"]
return map;
}
Building in workspace /usr/J2EE/JENKINS/jobs/TEST_GROOVY/workspace
[workspace] $ /bin/sh -xe /tmp/hudson50466.sh
+ echo MODULE_NAME:FPD
MODULE_NAME:FPD
+ echo MODULE_HOME:SSP-FPD
MODULE_HOME:SSP-FPD
Finished: SUCCESS