Inject environment variables plugin is passing value as "12345" - jenkins

I am using "Inject environment variables" Jenkins plugin to pass values to child jobs. Property file name is config.Today_date(eg. config.0403) and it has two parameters in it 1. change list(eg. 175444) 2. today's date(eg. 04032014). In child job Properties file path is config.${Today_date}($Today_date is predefined parameter in parent job).
First issue is: it error out saying config."Today_date" do not exist. I went to location and found property file is there and realized that child job is searching properties file as config."Today_date"(config."0403")and actual name of file is config.today_date
Second issue is: if i put property file name as config.0403(today_date) in Properties file path, Then it successfully locate the file but where ever it use parameters from this file, it use them as "0403" & "175444"
Please advise how i can solve "" issue at both locations.
Thanks !!

Related

Jenkins issue with Trigger one build per property file

Job A uses "For every property file, invoke one build" parameter factory to call downstream job B.
Here is the file pattern I am using:
d:\temp*.properties
There are two files in that folder:
build0.properties
build1.properties
each file looks something like this:
modified=SampleApp
Job B fails because job A is not setting the parameters from above file. If I look at the parameters for a build of Job B, they are empty.
The process works when I use "Parameters from properties file" parameter type instead of a parameter factory, and specify the full path to one of the files, so I know the files are in the right format. I do not want to add a parameter for each file I have,
since I will have these files generated dynamically.I would prefer to use the parameter factory if possible.
Issue with the file permissions, when I pointed to workspace directory with the file pattern It started workign fine.

Cannot receive parameter from Script content to Predefined Parameter in Jenkins

I would like to pass hostname parameter which is declared at Script Content to Predefined Parameter in Trigger/calls on build other project where my child project will receive parameter from the parent project.My code looks like this in Script Content:
`machine_name="$(hostname)"`
So in order to pass my parameter to the child project I declared:
host_name=${machinename}
in Script Content .But when I check in my child project it display as ${machinename} which is not I want .Can someone tell me what am I missing or what step that I done wrong or is there any way to perform this ?
Try using ENv Inject plugin, all you need to do is below:
Your script should contain below step:
machine_name="$(hostname)" > inject.txt
Now use Inject environment variables build step and in
property file path give inject.txt
what's the use?
By this step, now you machine_name variable holds the hostname value throughout the job.
Next, in your Parameter in Trigger/calls on build other project
host_name=${machine_name}
And use the same variable in child job.
I think there is no need for multiple assignments above, but still you can try this.
'_' was missing. host_name=$machine_name.
you cannot set or pass the parameter value from the script o/p. either make it as env variable using groovy or set in to property file & read.

Updating the Jenkins Variable with a value calculated in a batch file

I am new to Jenkins. My aim is to define a build job in which I have created an environment variable suppose "x" by checking "This build is parameterized" option. I am executing a batch file which is performing a set of instructions and I want the x to be updated by a value calculated in batch file. Any suggestions how can I update the Jenkins variable value calculated using a batch file. I have tried using enviject plugin but not getting how to update the variable.
Thanks in advance
enviject plugin should be helpful here.
But - you need to update your batchfile to create a property file.
As the first step in the build action, I am passing some properties to my test.
Then, I use the property name like a parameter passed to Jenkins to execute a windows batch command. This bat file creates a result file in .properties format.
As the third step, i read the (result) property file. The result property file can have the same properties with updated values.
Now - your original proeprties would have been updated with new values & can be used in your subsequent build steps.

Jenkins Parameterized Trigger Plugin passing value as "VALUE"

I am using "Parameterized Trigger Plugin" to trigger child job. I am passing predefined parameter as NUMBER=$VERSION_NUMBER and child job failed saying FILE_NAME."12345" do not exist. I went to location and found property file is there and realized that child job is searching properties file as FILE_NAME."12345"(FILE_NAME.$NUMBER) and actual name of file is FILE_NAME.12345, So root cause seems like that pligin is passing value with "".
Please suggest if there is a way to pass value without "".
Thanks !!
try using ${NUMBER} instead of $NUMBER

How to set Environment Variable so that it can be used in Jenkins

I am using an Environment Variable so that that it can be modified and Recipient List will consume that environment variable.
So this value is passed as a build parameter:
Followed to that I am modifying it. Just as an example:
Now I am accessing this value in the recipient list:
Unfortunately Jenkins is not able to get this new value. It is using the old value. How this behavior can be fixed?
We need to use the EnvInject Plugin. One of the features is a build step that allows you to "inject" parameters into the build job from a settings file.
Create a property for the email list in the env.properties file:
echo "email_list=`dummy#test.com`"> env.properties
It will create the properties file in the job workspace directory.
env.properties
In Recipient list access this variable using the following:
"$email_list"

Resources