Vijay
Vijay

Reputation: 23

How to override properties file using plugin in Jenkins?

In my Selenium-TestNG-Maven automation framework, I am have properties file for storing 'application-url'. The Jenkins job is configured for this. I have to run this test suite on QA/Stage/Production server based on need. But not sure how can I dynamically provide or override the 'application-url' property used in the code. (Environment Injector plugin? How?)

As per code, Selenium WebDriver instance in created, then java code reads the properties file and same URL is used by Selenium instance to open a webpage.

Upvotes: 1

Views: 3362

Answers (2)

Jasmine James
Jasmine James

Reputation: 66

I dynamically provide URLs by using the choice parameter for my Jenkins job.

First select this project is parameter as pictured below:

Jenkins Configuration Parameter

Then select the Add Parameter > Choice Parameter as pictured below:

Choice Parameter

Then save.

Now when you are building you will be able to select the url to use for that particular build, like this:

Choice selection

And when you need to reference the url, you can pass it through to maven by using the $URL in the Maven Goals.

ADDED: Here is an example of how I am using the choice parameter in the Maven goals

Maven goals

I am passing the ${browserName} parameter that is defined using the Choice Parameter through maven which will be referenced using the system property "browser". So when I want to get the value in my code, I just use

System.getProperty("browser");

And I am able to access that passed parameter.

Upvotes: 1

Paras
Paras

Reputation: 3235

You can configure your jenkins to pull the latest code from any of the repository (Github, SVN) and in the Execute Shell build step, you can write a shell script to achieve the same.

Upvotes: 0

Related Questions