This docker-based development environment is for new contributors of the Jenkins Warnings and Coverage Plugins to reduce the initial ramp-up time. It consists of the following parts:
I presented this development environment in a recorded Jenkins Online Meetup in January 2022.
The development environment has been tested on macOS, Ubuntu Linux (in a virtual machine running on macOS), and Windows. Pull requests are always welcome.
Latest version of the following tools:
Additionally, the latest versions of the following tools are required:
If errors occur, note the troubleshooting hints below. For Windows users: Use the Git Bash to execute the Shell scripts.
./bin/clone-repos-https.sh (or ./bin/clone-repos.sh if you already have set up an SSH key in GitHub). You must wait until the build succeeds before opening IntelliJ, otherwise IntelliJ will not find all generated classes. First time Maven users need to wait a couple of minutes until all dependencies have been downloaded from Maven central.warnings-ng-plugin-devenv./bin/jenkins.sh. This command builds the Jenkins Docker image, downloads all registered plugins and initializes the Jenkins workspace with some jobs. This requires some minutes as well (see Step 9).If all downloads have succeeded, but the installation failed due to errors, fix them
and execute mvn -V -U -e install –DskipTests to retry only the installation.
If the error "Command line is too long." occurs, execute following steps:
@argfile (Java9+)If tests fail due to a Jenkins test timeout, execute following steps:
-Djenkins.test.timeout=1000. This increases the timeout limit to 1000 seconds.You can use a simple shell script (./bin/clone-repos.sh) to clone and build the modules in a single step. The script checks out the following modules using the git SSH protocol. This requires that you have registered your public key in GitHub. If you have no keys in GitHub you can alternatively use the script ./bin/clone-repos-https.sh that uses the HTTPS protocol.
When you are planning to provide a pull request for one of the plugins you need to create a fork of the repository and make all changes in this fork. I created a GitHub collaboration documentation in my coding style project.
IntelliJ (Ultimate) is the main supported development environment for the Warnings plugin. A predefined project is stored
in the folder .idea that references all modules of the Warnings plugin. This project contains presets of my
coding style and some other helpful configurations.
It should be possible to use other IDEs (Eclipse, Netbeans, Visual Studio Code) as well.
Use the provided IntelliJ Run Configurations All in [module-name] to run the unit and integrations tests of the corresponding module. These configurations are already configured to record the branch coverage of the corresponding module packages (use the Run with Coverage action).
Before you can debug your changes, you first need to find out where your code is running: on the controller or on the agent? If you are unsure, then run both remote debuggers, set some breakpoints and wait for the corresponding debugger to stop.
The docker compose configuration starts the Jenkins controller automatically in 'Debug' mode, i.e., it is listening to remote debug requests. If your code runs in the controller, then you need to attach a remote debugger at localhost:8000 (mapped to the same port in the docker container). Use the provided Jenkins Controller (Remote Debugger) Debug configuration to connect a debugger in IntelliJ.
The docker compose configuration also starts the Jenkins agent automatically in 'Debug' mode, i.e., it is listening to remote debug requests. Attach a remote debugger at localhost:8001 (mapped to the same port in the docker container) to debug code that is running on the agent. Use the provided Jenkins Agent (Remote Debugger) Debug configuration to connect a debugger in IntelliJ.
UI tests can be started using the corresponding launchers UI Tests [module] (Firefox) or UI Tests [module] (Chrome). Note that both launchers require an installation of the corresponding Selenium drivers. If these drivers are not installed in /opt/bin on your local machine then you need to adapt the launcher configurations to match your setup.
All UI tests require running within a given subject under test (i.e, Jenkins under test, JUT), see Acceptance Test Harness project for more details.
This development environment contains a customized Jenkins installation where you can deploy your modified plugins to, so you can see your changes directly in some preconfigured jobs that use these plugins.
Start the provided Jenkins controller in this project (you need to install docker and
docker-compose). Open a terminal and run ./jenkins.sh
in the top level folder. This command is a wrapper to docker-compose up: it uses the right user and group settings
so that the permissions of the docker volume for the Jenkins home folder are correctly set.
This command creates a docker container for the Jenkins controller and one for the Java agent.
This will require some time when called the first time since the docker
images will be composed. After the images have been created the following two containers will be started:
You can then open Jenkins at the URL http://localhost:8080/. Use the following credentials to log in as administrator:
The home directory of the Jenkins controller (JENKINS_HOME) is mounted as a
docker volume. I.e., it is visible on the host as a normal directory at
./docker/volumes/jenkins-controller. It will survive sessions and can be changed directly on the host, see
official documentation for details.
This helps to inspect the files that have been created by the Jenkins controller.
Due to a performance problem in Jenkins' Job DSL plugin, setting up the new Jenkins instance is very slow.
Therefore, it makes sense to remove the job's configuration part of your jenkins.yaml file after the Jobs have been
created. You can overwrite the content of the file ./docker/volumes/jenkins-home/jenkins.yaml in your newly created
Jenkins instance with the content in jenkins-no-jobs.yaml.
Volumes under macOS are quite slow. On my MacBook running the provided Jenkins job of the analysis-model in the
docker container is slower than running the same Jenkins job in a docker container that is running in a linux virtual machine
on the same MacBook (sounds kind of absurd ?).
Once you finished your local development changes (i.e., the unit tests are all green) you should test your changes in Jenkins. This also helps to prepare an integration test or UI test for your change.
If you have only changes in the analysis-model module (and you added no new API methods) then you need to rebuild and install the maven module analysis-model.jar and afterwards rebuild the associated Jenkins wrapper plugin analysis-model-api-plugin. This plugin then needs to be deployed to Jenkins.
This process is simplified by running the script ./bin/go.sh in the analysis-model module, it will install the module analysis-model.jar in your local maven repository. Then this script will build the actual plugin and deploy it to Jenkins.
If you have only changes in the warnings-ng plugin then you need to rebuild the Jenkins plugin warnings-ng.jpi
and deploy it to Jenkins. You can use one of the following shell scripts for this task:
./bin/clean.sh: Builds the plugin using mvn clean install and deploys it on success into the Jenkins instance../bin/go.sh: Builds the plugin using mvn clean install -DskipITs (skips the integration tests)
and deploys it on success into the Jenkins instace../bin/skip.sh: Builds the plugin using mvn clean install -DskipTests (skips all tests and static analysis)
and deploys it on success into the Jenkins instance.TODO
If you have changes in one of the Foresics Plugins (API or Git implementation) then you need to rebuild these Jenkins plugins and deploy them into the Jenkins instance.
To simplify this process run the script ./go.sh in the corresponding plugin folder, it will build the
plugin and deploy it on success to Jenkins.
Before making breaking changes please get in touch with me. Typically, it is possible to make changes backward compatible.
The build scripts from the last section can also be started using one of the IntelliJ launchers
Build and Deploy [module-name].
These launchers build the corresponding plugin and deploy it into Jenkins.
UI tests can be started using an IntelliJ launcher configuration or using a command line script. As already mentioned, all UI tests require to run within a given subject under test. In our case we use the latest available Jenkins LTS version and the predefined set of plugins from our docker image.
UI tests can be started using the corresponding launchers UI Tests Warnings (Firefox) or UI Warnings Tests (Chrome).
Note that both launchers require an installation of the corresponding Selenium drivers. If these drivers are not
installed in /opt/bin on your local machine then you need to adapt the launcher configurations to match
your setup.
You can also start the UI tests using the provided shell scrips testFirefox.sh or testChrome.sh. Note that
you might need to adapt these scripts as well (see previous section).