Jenkins properties file

+5 votes

How to change values in .properties file and run a build using the values in jenkins?

Mar 26, 2018 in Jenkins by Atul
• 10,220 points
5,379 views

5 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
+2 votes

You can try to use the EnvInject Plugin for Jenkins which allows to inject environment variables into build process, and modify your .bat file to use them instead of reading values from the properties file.

Here are some of the plugin's usecases/features:

To remove inherited environment variables (PATH, ANT_HOME, ...) at node level (master/slave), available by default for a job run.
To inject variables in the first step of the job (before the SCM checkout)
To inject variables based on user parameter values
To execute an initialization script before a SCM checkout.
To execute an initialization script after a SCM checkout
To inject variables as a build step obtained from a file filled in by a previous build step
To know environment variables used for a build
To inject build cause as environment variable for a build
To inject environment variables from the evaluation of a Groovy script (powered by Script Security Plugin)
To export environment variables as a metadata in your binary repository

answered Mar 26, 2018 by DragonLord999
• 8,360 points

edited Oct 16, 2018 by Kalgi
@Dragonlord, what is the difference between .bat file and a .properties file?
+2 votes

Follow these steps:

1. Install ‘EnvInject’ plug-in in the Jenkins CI tool.

2. After installing ‘EnvInject’ plug-in, you will see ‘Inject environment variables’ option under ‘Add Build Step’.

3. Configure the plug-in with Jenkins job by clicking on ‘Inject environment variables’ option.

4. You will see two fields: ‘Properties File Path’ and ‘Properties Content’ field after adding ‘Inject environment variables’.

5. In ‘Properties File Path’ field, provide the path of the properties file, i.e. where it exists in the Automation project and in ‘Properties Content’ field, provide all the information that you want to change in the run time

6. Now, run the Jenkins’s job to set all the ‘Properties Content’ field data into environment variable of target Virtual machine temporarily.

7. Get the properties data from the System environment variables and update the properties file.  This can be done by configuring the build.xml file

answered Aug 2, 2018 by lina
• 8,100 points
If build.xml file is already exist, where can i find it? if i want to create newly please let me know how to create.
0 votes

To change the property values, open the output stream and store properties after you have closed the input stream.

FileInputStream in = new FileInputStream("First.properties");
Properties props = new Properties();
props.load(in);
in.close();

FileOutputStream out = new FileOutputStream("First.properties");
props.setProperty("country", "america");
props.store(out, null);
out.close();
answered Oct 16, 2018 by Kalgi
• 36,260 points
0 votes

You can use the EnvInject plugin. This plugin makes it possible to have an isolated environment for your jobs.

answered Dec 6, 2018 by Sai
0 votes

Use cases of the EnvInject plug-in:

  • To remove inherited environment variables (PATH, ANT_HOME, ...) at node level (master/slave), available by default for a job run.
  • To inject variables in the first step of the job (before the SCM checkout)
  • To inject variables based on user parameter values
  • To execute an initialization script before a SCM checkout.
  • To execute an initialization script after a SCM checkout
  • To inject variables as a build step obtained from a file filled in by a previous build step
  • To know environment variables used for a build
  • To inject build cause as environment variable for a build
  • To inject environment variables from the evaluation of a Groovy script 
  • To export environment variables as a metadata in your binary repository
answered Dec 6, 2018 by Kunal

Related Questions In Jenkins

0 votes
2 answers
+1 vote
3 answers

Rename jobs from jenkins file

Go to the Configure screen and edit the Project name field ...READ MORE

answered Oct 25, 2018 in Jenkins by Laila
416 views
+1 vote
1 answer
0 votes
2 answers

"No such file pom.xml" error in Jenkins

Can you please che ck the location ...READ MORE

answered May 15 in Jenkins by Samir
120 views
+1 vote
2 answers

What possible return values are there in Jenkins plugin “Sonarqube scanner”

Use Webhooks in SonarQube Administration setup to ...READ MORE

answered Aug 3, 2018 in Jenkins by Nilesh
• 6,900 points
1,200 views
+13 votes
2 answers
0 votes
1 answer

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.