2015-04-27 05:23:50 +08:00
# Contributing to Jenkins
2017-10-04 18:19:20 +08:00
2017-10-05 04:54:01 +08:00
This page provides information about contributing code to the Jenkins core codebase.
2017-10-04 18:19:20 +08:00
2020-10-26 17:52:42 +08:00
:exclamation: There's a lot more to the Jenkins project than just code. For more information on the ways that you can contribute to the Jenkins project, see [Participate].
2017-10-04 18:19:20 +08:00
## Getting started
1. Fork the repository on GitHub
2. Clone the forked repository to your machine
2020-10-26 17:52:42 +08:00
3. Install the necessary development tools. In order to develop Jenkins, you need the following:
2019-10-16 18:37:11 +08:00
* Java Development Kit (JDK) 8 or 11.
2020-10-26 17:52:42 +08:00
In the Jenkins project we usually use [OpenJDK ](http://openjdk.java.net/ ) or [AdoptOpenJDK ](https://adoptopenjdk.net/ ), but you can use other JDKs as well.
2019-10-16 18:37:11 +08:00
* For JDK 11 there might be some compatibility issues in developer tools,
please see [this page ](https://wiki.jenkins.io/display/JENKINS/Java+11+Developer+Guidelines#Java11DeveloperGuidelines-Knowndevelopertoolsissues ) for more info.
2020-10-26 17:52:42 +08:00
If you find a new issue, please report it with a `java11-devtools-compatibility` label in our issue tracker.
* Maven 3.5.4 or above. You can [download Maven here].
2018-09-15 01:25:16 +08:00
* Any IDE which supports importing Maven projects.
2020-10-26 17:52:42 +08:00
* Install [NodeJS ](https://nodejs.org/en/ ). **Note:** only needed to work on the frontend assets found in the `war` module.
* Frontend tasks are run using [yarn ](https://yarnpkg.com/lang/en/ ). Run `npm install -g yarn` to install it.
4. Set up your development environment as described in [Preparing for Plugin Development]
2017-10-04 18:19:20 +08:00
2020-10-26 17:52:42 +08:00
If you want to contribute to Jenkins, or just learn about the project,
2017-10-05 04:54:01 +08:00
you can start by fixing some easier issues.
In the Jenkins issue tracker we mark such issues as `newbie-friendly` .
2020-10-26 17:52:42 +08:00
You can find them by using this query (check the link) for [newbie friendly issues].
2017-10-04 18:19:20 +08:00
## Building and Debugging
2020-10-26 17:52:42 +08:00
The Jenkins core build flow is built around Maven.
You can read a description of the [building and debugging process here].
2017-10-04 18:19:20 +08:00
2020-10-26 17:52:42 +08:00
If you want simply to build the `jenkins.war` file as fast as possible without tests, run:
2017-10-04 18:19:20 +08:00
2019-11-13 00:29:21 +08:00
```sh
2021-05-08 04:04:58 +08:00
mvn -am -pl war,bom -DskipTests -Dspotbugs.skip -Dspotless.check.skip clean install
2019-11-13 00:29:21 +08:00
```
2017-10-04 18:19:20 +08:00
2017-10-05 04:54:01 +08:00
The WAR file will be created in `war/target/jenkins.war` .
2020-10-26 17:52:42 +08:00
After that, you can start Jenkins using Java CLI ([guide]).
If you want to debug the WAR file without using Maven plugins,
You can run the executable with [Remote Debug Flags]
2017-10-04 18:19:20 +08:00
and then attach IDE Debugger to it.
2020-10-26 17:52:42 +08:00
To launch a development instance, after the above command, run:
2019-10-30 22:56:35 +08:00
2019-11-12 22:25:43 +08:00
```sh
2019-11-13 21:42:38 +08:00
mvn -pl war jetty:run
2019-11-12 22:25:43 +08:00
```
2019-10-30 22:56:35 +08:00
2020-10-26 17:52:42 +08:00
(Beware that `maven-plugin` builds will not work in this mode, due to class loading conflicts.)
2019-11-12 23:03:04 +08:00
2020-01-22 01:27:03 +08:00
### Building frontend assets
2020-10-26 17:52:42 +08:00
To work on the `war` module frontend assets, two processes are needed at the same time:
2020-01-22 01:27:03 +08:00
On one terminal, start a development server that will not process frontend assets:
```sh
mvn -pl war jetty:run -Dskip.yarn
```
On another terminal, move to the war folder and start a [webpack ](https://webpack.js.org/ ) dev server:
```sh
cd war; yarn start
```
2017-10-04 18:19:20 +08:00
## Testing changes
2017-10-05 04:54:01 +08:00
Jenkins core includes unit and functional tests as a part of the repository.
2017-10-04 18:19:20 +08:00
2020-10-26 17:52:42 +08:00
Functional tests (`test` module) take a while to run, even on server-grade machines.
2017-10-05 04:54:01 +08:00
Most of the tests will be launched by the continuous integration instance,
2017-10-04 18:19:20 +08:00
so there is no strict need to run full test suites before proposing a pull request.
2018-10-06 21:01:00 +08:00
There are 3 profiles for tests:
2020-10-26 17:52:42 +08:00
* `light-test` - runs only unit tests, no functional tests
* `smoke-test` - runs unit tests + a number of functional tests
* `all-tests` - runs all tests, with re-run (default)
2018-10-06 21:01:00 +08:00
2017-10-05 04:54:01 +08:00
In addition to the included tests, you can also find extra integration and UI
2018-09-15 01:25:16 +08:00
tests in the [Acceptance Test Harness (ATH)] repository.
2017-10-05 04:54:01 +08:00
If you propose complex UI changes, you should create new ATH tests for them.
2017-10-04 18:19:20 +08:00
2020-01-22 01:27:03 +08:00
### JavaScript unit tests
In case there's only need to run the JS tests:
```sh
cd war; yarn test
```
2017-10-04 18:19:20 +08:00
## Proposing Changes
2018-10-27 04:56:06 +08:00
The Jenkins project source code repositories are hosted at GitHub.
2020-10-26 17:52:42 +08:00
All proposed changes are submitted, and code reviewed, using the _GitHub Pull Request_ process.
2017-10-05 04:54:01 +08:00
To submit a pull request:
2017-10-04 18:19:20 +08:00
2020-10-26 17:52:42 +08:00
1. Commit your changes and push them to your fork on GitHub.
2017-10-04 18:19:20 +08:00
It is a good practice is to create branches instead of pushing to master.
2020-10-26 17:52:42 +08:00
2. In the GitHub Web UI, click the _New Pull Request_ button.
3. Select `jenkinsci` as _base fork_ and `master` as `base` , then click _Create Pull Request_ .
* We integrate all changes into the master branch towards the Weekly releases.
* After that, the changes may be backported to the current LTS baseline by the LTS Team.
Read more about the [backporting process].
2018-09-15 01:25:16 +08:00
4. Fill in the Pull Request description according to the [proposed template].
2020-10-26 17:52:42 +08:00
5. Click _Create Pull Request_ .
2017-10-04 18:19:20 +08:00
6. Wait for CI results/reviews, process the feedback.
2020-04-16 15:36:21 +08:00
* If you do not get feedback after 3 days, feel free to ping `@jenkinsci/core-pr-reviewers` in the comments.
2020-10-26 17:52:42 +08:00
* Usually we merge pull requests after 2 approvals from reviewers, no requested changes, and having waited some more time to give others an opportunity to provide their feedback.
See [this page ](/docs/MAINTAINERS.adoc ) for more information about our review process.
2017-10-04 18:19:20 +08:00
2017-10-05 04:54:01 +08:00
Once your Pull Request is ready to be merged,
2020-10-26 17:52:42 +08:00
the repository maintainers will integrate it, prepare changelogs, and
ensure it gets released in one of upcoming Weekly releases.
2017-10-17 04:42:23 +08:00
There is no additional action required from pull request authors at this point.
2017-10-04 18:19:20 +08:00
2021-01-09 16:35:54 +08:00
## IntelliJ suggestion
In case you are using IntelliJ, please adjust the default setting in respect to whitespace fixes on save.
The setting can be found in Settings -> Editor -> General -> On Save -> Remove trailing spaces on: `Modified lines`
This will help minimize the diff, which makes reviewing PRs easier.
We also do not recommend `*` imports in the production code.
Please disable them in Settings > Editor > Codestyle > Java by setting _Class count to use import with '*'_ and Names count to use import with '*'_ to a high value, e.g. 100.
2017-10-04 18:31:46 +08:00
## Copyright
2020-10-26 17:52:42 +08:00
The Jenkins core is licensed under [MIT license], with a few exceptions in bundled classes.
2017-10-04 19:59:07 +08:00
We consider all contributions as MIT unless it's explicitly stated otherwise.
MIT-incompatible code contributions will be rejected.
2020-10-26 17:52:42 +08:00
Contributions under MIT-compatible licenses may also be rejected if they are not ultimately necessary.
2017-10-04 18:31:46 +08:00
2018-09-15 01:25:16 +08:00
We **Do NOT** require pull request submitters to sign the [contributor agreement]
2020-10-26 17:52:42 +08:00
as long as the code is licensed under MIT, and merged by one of the contributors with the signed agreement.
2017-10-04 18:31:46 +08:00
2017-10-17 04:42:23 +08:00
We still encourage people to sign the contributor agreement if they intend to submit more than a few pull requests.
2017-10-05 04:54:01 +08:00
Signing is also a mandatory prerequisite for getting merge/push permissions to core repositories
2020-10-26 17:52:42 +08:00
and for joining teams like the [Jenkins Security Team].
2017-10-04 18:31:46 +08:00
2017-10-04 18:19:20 +08:00
## Continuous Integration
2017-10-05 04:54:01 +08:00
The Jenkins project has a Continuous Integration server... powered by Jenkins, of course.
2018-09-15 01:25:16 +08:00
It is located at [ci.jenkins.io].
2017-10-04 18:19:20 +08:00
2018-09-15 01:25:16 +08:00
The Jenkins project uses [Jenkins Pipeline] to run builds.
The code for the core build flow is stored in the [Jenkinsfile] in the repository root.
2017-10-05 04:54:01 +08:00
If you want to update that build flow (e.g. "add more checks"),
just submit a pull request.
2015-04-27 05:23:50 +08:00
2017-10-04 18:31:46 +08:00
# Links
2021-05-26 03:56:16 +08:00
* [Jenkins Contribution Landing Page ](https://www.jenkins.io/participate/ )
* [Jenkins IRC Channel ](https://www.jenkins.io/chat/ )
2017-10-04 18:31:46 +08:00
* [Beginners Guide To Contributing ](https://wiki.jenkins.io/display/JENKINS/Beginners+Guide+to+Contributing )
2021-09-14 03:07:44 +08:00
* [List of newbie-friendly issues in the core ](https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened )%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly))
2017-10-04 18:31:46 +08:00
2021-05-26 03:56:16 +08:00
[Preparing for Plugin Development]: https://www.jenkins.io/doc/developer/tutorial/prepare/
2021-09-14 03:07:44 +08:00
[newbie friendly issues]: https://issues.jenkins.io/issues/?jql=project%20%3D%20JENKINS%20AND%20status%20in%20(Open%2C%20%22In%20Progress%22%2C%20Reopened)%20AND%20component%20%3D%20core%20AND%20labels%20in%20(newbie-friendly)
2021-05-26 03:56:16 +08:00
[Participate]: https://www.jenkins.io/participate/
[building and debugging process here]: https://www.jenkins.io/doc/developer/building/
2018-09-15 01:25:16 +08:00
[guide]: https://wiki.jenkins.io/display/JENKINS/Starting+and+Accessing+Jenkins
[Remote Debug Flags]: https://stackoverflow.com/questions/975271/remote-debugging-a-java-application
[Acceptance Test Harness (ATH)]: https://github.com/jenkinsci/acceptance-test-harness
2021-05-26 03:56:16 +08:00
[backporting process]: https://www.jenkins.io/download/lts/
2018-09-15 01:25:16 +08:00
[proposed template]: .github/PULL_REQUEST_TEMPLATE.md
[MIT license]: ./LICENSE.txt
2021-05-26 03:56:16 +08:00
[contributor agreement]: https://www.jenkins.io/project/governance/#cla
[Jenkins Security Team]: https://www.jenkins.io/security/#team
2018-09-15 01:25:16 +08:00
[ci.jenkins.io]: https://ci.jenkins.io/
2021-05-26 03:56:16 +08:00
[Jenkins Pipeline]: https://www.jenkins.io/doc/book/pipeline/
2019-10-10 01:27:26 +08:00
[Jenkinsfile]: ./Jenkinsfile
2020-12-28 00:36:55 +08:00
[download Maven here]: https://maven.apache.org/download.cgi