Automated Test Automation using Jenkins

Configuring webhooks from your code repository is a great way to incrementally step towards 'automated' test automation (tests that run without you having to manually click run). This will help you practically step toward continuous testing which underpins a mature CI/CD practice.

In this log post lets explore how we set this up using a local Jenkins instance, in a few simple steps.

Note - in this example we're using BitBucket cloud, running Jenkins locally on macOS. To keep this as concise as possible this blog assumes basic working knowledge of each component system to set up this pipeline and you have each component installed, therefore specific installation and configuration steps are skipped.

If you would like more detail please let us know we'll gladly produce more useful content!

So assuming you have Jenkins installed and running locally, the first step is to create then configure a pipeline in your local Jenkins server. In this case the pipeline steps to be defined by a Jenkinsfile, stored in your test automation project. Specific the URL to the repository, like the example screenshot above.

If you haven't worked with a Jenkinsfile before, get some background here -

To make this example work you'll need to install the BitBucket Jenkins plug-in -

Next, for a webhook to reach your local server, you'll need to expose it to the outside world. This can be easily achieved using a service like ngrok - Follow the instructions on here for your setup, until you get to the point of having something that looks like the imagine below.

Note - you'll need to expose the same port that Jenkins runs on locally, 8080 normally, but that checked and changed if needed in a config file.

You'll need to make note of (or copy) whichever of the http or https forwarding url's you would like to use, example outlined in pink above.

At the time your reading this the address above will NOT be associated with my local machine!!

So now your machine is exposed to the world (ngrok supports protecting your tunnel with a password - ), you can set up a webhook from your code repository.

In the case of BitBucket you grab your forwarding address (copied in the previous step), and append /bitbucket-hook/. You can specific whether the hook is trigger by a repo push, or via another trigger. Examples of what you'll see below.

Are you new to BitBucket cloud? Resourced to get started here

Below is a small screenshot of the Jenkinsfile, in this case living at the top level of the repo for the demo test automation project I'm using.

Below is the contents of the Jenkinsfile in using for this blog, which is extremely simple. In this case it is checking out another project from a different repository (example use case is you have your test project code in a separate repository to your development project and you want to trigger the tests from the common pipeline).

The next stage in the pipeline is to simply run the tests using the mvn clean test command, as we've used Maven as the build too in this project

Bringing it all together.

Now that all the separate parts are configured, we can push to the repository from your IDE or terminal, and watch the pipeline checkout the project and run the tests.

You can (and should!) progress to running this from your central CI Server, integrating this in to the delivery pipeline your team is using.

What are the benefits?

Anytime you update the project, commit then push, the tests you've written will run. This will give you fast feedback on both the health of the tests you've crafted, and most crucially fast feedback on the quality of the development project we are testing against. All without clicking a button to execute.

This could be your first step towards practically implementing continuous testing.

Thank you for using your time to read this post, we hope you found it useful!

For more information on this topic, or anything related to Software Testing and Quality Assurance, please reach out to us at, or

Sign up to our email list for our FREE 6 part series on how to get the most out of your test automation

The TechnoCentre, Coventry University Technology Park, Puma Way, Coventry CV1 2TT, UK

  • LinkedIn
  • Twitter

©2020 Loupe Testware - All Rights Reserved | Registered & England and Wales - Company No. 11407097 - VAT No. 303875406 | Privacy Policy