Jenkins is a highly regarded open-source automation tool that facilitates some integral technical capabilities used in the continuous delivery process. It’s primary usage pattern is to execute functional test automation and performance test suites to validate against software builds.

Using Jenkins with Flood to schedule performance tests utilises our very powerful Flood API. When a Jenkins build has completed you can automatically trigger a load test via the following simple process.

Creating your load test enabled Jenkins project

Create a new Freestyle project and click OK

You will be directed to a General settings area. Enter a short meaningful description of this project - such as the following:

Select the option This project is parameterized and add a File parameter as follows:

Add as many file parameters as your load test requires. You will need at least one for your test script. If you are using CSV data files - then a file parameter is needed for each file.

The test script name such as Script.jmx denotes it as a JMeter script file. If you want to use Flood Element use the .ts extensions, .java extension for Selenium and .scala extension for Gatling.

Adding the load test trigger

Once we have added the file parameters - we need to setup a Build command that will run our script automatically on Flood.

From the Build Triggers tab, go to the Build section and add a new Build step

Select the option Execute shell and paste the following curl command:

curl -u <YOUR_API_KEY>: -X POST https://api.flood.io/floods \
  -F "flood[tool]=jmeter" \
  -F "flood[threads]=10" \
  -F "flood[rampup]=60" \
  -F "flood[duration]=300" \
  -F "flood[privacy]=public" \
  -F "flood[name]=Jenkins Test" \
  -F "flood_files[]=@Script.jmx" \
  -F "flood_files[]=@Data.csv" \
  -F "flood[grids][][infrastructure]=demand" \
  -F "flood[grids][][instance_quantity]=1" \
  -F "flood[grids][][region]=us-west-2" \
  -F "flood[grids][][instance_type]=m5.xlarge" \
  -F "flood[grids][][stop_after]=60"

*Please ensure you use your own API token and replace the <YOUR_API_KEY> with your generated token. Please see below on how to get your Flood API token.

More details about the parameters here, to get your API token, go to you Flood account and then click on the API Access menu. 

Click on reveal token link to get the token value.

Finally, click Apply and then Save the project. 

You can click on the Build with Parameters menu item within your newly created project as follows:

Once clicked, simply select the correct files from your local computer and click Build. 

Once the test is running, monitor it from your Console Output and Flood Dashboard to ensure that the test has been launched. 

The console output should look similar to the following:

Of particular note, is the Finished: SUCCESS message being returned as part of the response. Also, a URL link to the live running test dashboard is given as the permalink value.

A word about security

Using your Flood API token on a Jenkins environment allows potential third party services or other users to launch any kind of load test using your account. If you think your API token or Flood Account has been compromised you should delete and re-generate the corresponding token from your account to prevent further unwanted use.

Putting it all together

Combining Jenkins and a load test tool gives you the ability of potentially tracking your application’s performance over time. It allows you to pinpoint what build introduced a performance regression or even a performance benefit.  

Flood enables you to run load tests from a handful of users to potentially millions of concurrent users.  The free trial we offer will provide you with enough node hours to execute a load test using a tool such as Flood Element for 15 minutes with roughly 1,000 concurrent users.

If you are running continuous load testing using Jenkins or another CI tool, we’d love to hear from you.  Drop us a note and share any ideas that are working for you and feel free to ask our team any of your tough questions!

Did this answer your question?