There are a lot of tutorials, but each covers only part of the process, I can not find a simple and understandable for a beginner, covering the whole process.

What I want:

  1. There is a Java application (moreover, it can be either a web application launched in the same Tomcat, or a regular console application or library compiled into a jar)

  2. Unit and integration tests are written.

  3. The application is going to gradle.

  4. Deploy an Artifactory with a repository where I want to deploy the builds.

Actually the process that I want to set up:

  • At each push on the server unit-tests, integration tests are run, the code coverage by tests, codestyle, etc. is analyzed.

  • If everything is good, the assembly is deployed in the Artifactory, and also (if the application is a web), it is updated and restarted on the dev server.

  • Or to have some page, which is a table: download link - commit message (for example: http://abrok.eu/stockfish/ )

  • If something went wrong, the response with the description comes in the mail (for example)

It would be great to see the tutorial from scratch, when a helloWorld Java project is created, how Jenkins is configured, what happens when a commit is made, etc. Those. tutorial, where java code is written and changed simultaneously with the Jenkins setting.

It may not be necessary to completely describe the process I described, but some tutorial that simplifies the development process (change, writing tests, commits) a java application with jenkins running.

  • 2
    I also want to be able to do all this, a very good deal - CDCI. But the question is not very clear as a result. Do you want to be given a link to a tutorial? Surely this will not happen. The question as a whole is very broad and cannot be answered briefly. Let's somehow break it down into concrete subtasks about each of which you can ask "how to do A correctly." - Nick Volynkin
  • In general, there is almost certainly no tutorial on the whole process for this very reason - there are several processes independent of each other. - Nick Volynkin
  • Since I understand that the processes are dependent on each other, after pushing - the test run, then the result. If you can simplify it like this: git-push - run unit tests - alert (in any form) about the results. And the second subtask, then how to integrate additional processes into the process (for example, insert another verification of the style code or deployment after the style code) - this is even more important, since there can be different numbers of subprocesses and they can be started in a different order. - Evgeny Vasin September
  • Simply running the Unit tests is done easily in maven. Surely there are funds in Gradle. These processes are dependent on each other, but still separate. Each of the steps in your process can be done with different tools, each is worth asking a separate question. If you answer your question completely and completely - you can write a whole book))) - Nick Volynkin
  • If you are not familiar with git-flow, then you will surely be interested. You can start with a description of the label: git-flow . - Nick Volynkin

1 answer 1

If you focus on organizing the build process with Jenkins tools, you’ll get something like the following:

At each push on the server unit-tests, integration tests are run, the code coverage by tests, codestyle, etc. is analyzed.

For the project (job), the trigger is set to the "Scan SCM about changes" assembly and the Git check schedule for the presence of fresh commits, for example, once every 10 minutes. Schedule is given in crontab format: H/10 * * * * .

Another option is to select the "Trigger builds remotely (eg, from scripts)" trigger and set up a post-commit hook in the repository, which will notify Jenkins of the presence of new commits. For this it is enough to pull the address http://<jenkins_server>/job/<job_name>/build .

The test run is performed by gradle. Install the Gradle Plugin on the build server and call gradle as the main build step, as if you were running it on a local machine. If the build includes a test run, jenkins will save the result information.

If everything is good, the assembly is deployed in the Artifactory, and also (if the application is a web), it is updated and restarted on the dev server.

Put the Artifactory Plugin and add the post-assembly step "Deploy artifacts to Artifactory" .

A redeploy application is better to be rendered into a separate project, which will be called after the main assembly via the Post Build Operation "Build other project" . To "reach out" from the deployment project to the artifacts of the main assembly, install the Copy Artifacts Plugin . You will be available to the assembly step "Copy artifacts from another project", which will copy the necessary files from the source (upstream) assembly.

The deployment procedure itself can be implemented using Jenkins tools (for example, Deploy Plugin ), using gradle tools (for example, gradle-cargo-plugin ), or simply using a shell script.

If something went wrong, the response with the description comes in the mail (for example)

This Jenkins is able out of the box, it is enough to enable the "E-mail Notification" checkbox in the project settings. But I recommend to install the Email-ext plugin - it allows you to customize the events for the letter and the content more flexibly.