In this walkthrough I am going to show you how to locally use this ATH to test changes made in a local copy of Jenkins.
In this walkthrough I will be using Docker, IntelliJ and a terminal.
- Make your own fork of https://github.com/jenkinsci/jenkins
- Clone the fork to your local machine
Note The next two steps are optional, this makes it easy to make a PR to Jenkins if you wish to do so later
- Create a new branch and give it a sensible name
- Make your changes to your copy of Jenkins, commit changes to your branch, feel free to push your changes to your local fork
- When you have made changes to your local copy of Jenkins, in a terminal window
cd
into your local copy of Jenkins and runmvn verify
, this will run the integration tests inside the jenkins repo.
When you are ready to test your changes with this ATH, you will need to run mvn package
on your local copy of Jenkins. Navigate in your local Jenkins repo to …\war\target
and you will see a war file for you to use later.
- Clone a copy of this ATH repo to your local machine and
cd
into the directory
Note: There are many ways to run these tests, I will be running the tests using Windows, your commands may differ slightly if using a different OS. See the README.md for alternatives and configuration options.
- In a terminal window type
set JENKINS_WAR=C:\Users\julie\jenkins\war\target\jenkins.war
This sets a new environment variable calledJENKINS_WAR
to the path of your copy of the jenkins war (You created this in themvn package step
, change it to your directory path instead of mine) - Type
vars.cmd
to the same terminal window. This is a script for setting all the variables in order to run the ATH locally on windows, it also outputs a docker command. - Copy the docker command that was output to your terminal after the last step, and paste it into the same terminal window. This will run the docker container with your local copy of Jenkins.
You are now ready to run tests.
If you want to run all the tests, run mvn test
, if you want to run a specific test run mvn test -Dtest=ArtifactsTest
(change the test name to the one you wish to run) tests can be found in the src/test/java directory of this ATH repository.
- When running your tests with
mvn test
, adding the parameter-DforkCount=
with a number higher than 1 will run tests in parallel. This is useful for running tests in a shorter amount of time. See here for more details. - If you make changes to your local jenkins version after running ATH tests, and you want to re-run the tests again, make sure you run
mvn package
again in your local jenkins repository
Note: there are lots of good IDEs out there, I will be using IntelliJ for this walkthrough.
- Open the ATH in Intellj and add your breakpoints to the test(s) you want to debug.
- Click 'edit configuration' and add a new ‘Remote JVM Debug’
- Check these settings:
- Debugger mode =
Attach to remote JVM
- Transport =
Socket
- Host =
localhost
- Port =
5005
- Command line arguments for remote JVM =
-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005
- Click apply and ok
- Debugger mode =
Now go back to your terminal window which is pointed at the acceptance test local repo.
- I want to debug the
InstallWizardTest
, so I type into the terminalmvn test -Dtest=InstallWizardTest -Dmaven.surefire.debug
- As soon as you click the debug button on your intellij window, the test will run and stop at your breakpoints.
For more information on maven debugging, see here.