Possible to replace tokenized values within a .properties file within Jenkins?
Iam running an automation project in Jenkins which uses Java, I have a central config.properties file, is there a feature within Jenkins which would enable me to replace tokenized values via the Jenkins portal?
Current Config .properties File:
<!--BROWSER TYPE: chrome | firefox -->
browser=#{browserType}#
<!--BASE BAG HOMEPAGE URL: www.google.com
url=#{homepageUrl}#
<!--Username: example21@mail.com !-->
username=#{username}#
I need to replace all values which are contained within: #{}# therefore if i set the variable: browser with the value chrome then jenkins would replace the value and the end product would be:
<!--BROWSER TYPE: chrome | firefox -->
browser=chrome
AFAIK, properties files are not updated on the fly , you can use a sed instead
sed -i "s|#{browserType}#|${browser_jenkins build_variable}|g" Config .properties
browser_jenkins build_variable : This would a build parameter which you select when building the job
Updated solution :
update your Config.properties file as
browser=browser_value
Use a execute shell and use below command
sed -i "s|browser_value|${browser_value}|g" Config.properties
The above command should replace the browser_value string in config.properties with the option you select in jenkins job choice parameter