Forum Discussion
Here is the approach:
Define a project property say, ACTIVATE_PROFILE say QA.
One can modify the property value any time when it is used in the ReadyAPI tool.
In the Project's Load script, use below script:
//Add the environment names in the below if there are more;
//pass the key to load the respective environment
def envMap = [QA: 'Public QA', QA2: 'Public QA2', UAT: 'Public UAT', ENV1: 'Public ENV1', SITE: 'Public SITE']
def profile = project.getPropertyValue('ACTIVE_PROFILE')
if (envMap.containsKey(profile)) {
println 'Found the environment and activating'
def env = project.getEnvironmentByName(envMap[profile])
project.setActiveEnvironment(env)
} else {
println 'NO suitable environment found, pass the right value and retry!'
System.exit(1)
}
From the command line and jenkins, one can pass the project property value (without modifying the same in the project file) as below to activate UAT environment:
-PACTIVATE_PROFILE=UAT
Thanks richie for the quick response.
nmrao Thanks for your help. I followed the instructions and restarted ReadyAPI 3.49.0. The program would not start. I had to move the composite project folder to another directory so ReadyAPI wouldn't pick it up upon load. The program started after this. When I try to import the automation project ReadyAPI closes immediately.
Any idea what happened here? I need to restore my project as it has over a month of work. I imagine I have to edit some .XML now?
Edit I was able to get the script out of the XML and can now load the project. I think it was a conflict of what env it opened with and what env I specified in ACTIVE_PROFILE.
Related Content
Recent Discussions
- 22 days ago