I am new to Jenkin Pipeline. We have maven based selenium-java Automation framework. I am creating a Jenkin Pipeline groovy script to invoke the Automation framework.
In the framework we have config.properties file in which Application url , username and password is stored.
config.properties:
Url=https://#########/login.jsp
Username=########
Password=########
Requirement: We need to take the Application URL , Username and Password as a Jenkin parameter , and run the automation suite accordingly.
Question: From Pipeline groovy script how can I update the config.properties file at runtime? Is there any possibility of creating a java class inside the framework to update config file and invoke the java class from groovy script.
I've tried the following code
node{
stage("props file"){
script {
def props = """Url=https://#########/login.jsp Username=########
Password=########"""
writeFile interpolate: true ,file: 'ui-automation/fw/config/config.properties', text: props
def str = readFile file: 'ui-automation-fw/config/config.properties'
echo str
}
}
}
Appreciate any help on how to fix the code to achieve the needed result