Configuring the Jenkins CI job

In this chapter, the sample solution is in the ch10-nerd-dinner folder. It's the modernized NerdDinner application that has evolved over the previous chapters. There's a Dockerfile for every component. This uses a multi-stage build, and a set of Docker Compose files for building and running the application.

The folder structure here is worth looking at to see how distributed applications are usually arranged—the src folder contains all the application and database source code, the docker folder contains all the Dockerfiles, and the compose folder contains all the Compose files.

I've created a freestyle job in Jenkins to run the build, and configured Git for source code management. It's simple to configure Git—I'm using the same repository URL that I use for the Git repository on my laptop, and I've selected the Gogs credentials so that Jenkins can access them:

Jenkins is running in a Docker container, and Gogs is running in a container on the same Docker network. I'm using the hostname gogs, which is the container name, so that Jenkins can reach the Git server. On my laptop, I've add gogs as an entry in my hosts file, so I can use the same repository URL in development and on the CI server.

Jenkins supports multiple types of build triggers. In this case, I'm going to poll the Git server on a set schedule. I'm using H/5 * * * * as the schedule frequency, which means Jenkins will check the repository every five minutes. If there are any new commits since the last build, Jenkins will run the job.

That's all the job configuration I need, and all the build steps will now run using Docker containers.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.12.166.255