So before we get right into it here are few highlights of what’s to come ahead. We are going to use plugin to create our Jenkins job. T he cool part of using this plugin is that our entire Jenkins job configuration can be created, updated and version controlled along with the rest of our source code. Along with that, we will be using the magical powers of docker and docker-com pose to set up our entire CI infrastructure out of thin air! Exciting, right? We recommend that you follow along with us and get your hands dirty as its much more fun! Go ahead and fork the and switch over to branch. Here’s what we are going to learn this time: • • • • • • • • • • • • Let’s dive right into it. The High-Level Flowchart of CI Pipeline Using Jenkins Let’s see what a “very” high-level view of our Continuous Integration (CI) Pipeline usin g Jenkins looks like. High-Level CI flow using Jenkins The flow diagram is easy to understand however, there are few things to note, • You may wonder as to where the code compilation and unit-test ste ps are? Well, the docker run step performs both the code compile and the application publish! • The dotted line marks the boundary of our CI tool, Jenkins, in this example • Having the docker push after a successful run of the “Integration Tests” ensures that only tested application is promoted to the next region, another very important rule of Continuous Integration (CI) Setting up CI Infrastructure-As-Code Using Docker Let’s get into the fun stuff now. Setting up our Jenkins infrastructure! Although there are many things to love about the there is something that is. Let’s say “a little inconvenient”? Let’s see what that little thing is. Set up Jenkins. These are the basic configuration steps to use Jenkins in our testing deployment scenario. Ensure that you have 64-bit version of Jenkins running. Go to Manage Jenkins > System Information and verify that the value of the java.vm.name is '64-Bit'. If not, you must configure Jenkins to use Java x64 before continuing. December 9, 2018 December 18, 2018 HuuPV Docker 1 Comment on Set up Jenkins with docker In this tutorial, Quick start with jenkins in docker. Jenkins is a automation CI/CD tool. With jenkins, you can create jobs to build, test and deploy your application. When we run the following docker command. Slave start-up script The “ wait for the master” logic is going to come in very handy when we wrap the master and slave into a docker-compose file. The depends_on: tag in docker-compose doesn’t serve as well, as the jenkins master takes more time to be fully up and running than what docker-compose estimates it to be. Thus, it’s added intelligence to our slave. Let’s build this container and warp our Jenkins infrastructure into a docker-compose file! Building an Image and Exposing the Docker Daemon to the Agent. Configure Project Writing a Jenkins File The Jenkins file is a groovy based script which lists the different stages and steps of the Jenkins build. The benefits of this approach over using a freestyle job revolves mainly around flexibility and the ability to be able to version control. Let’s discuss a little more about these 2 points, Flexibility: Usually, a freestyle job will be created to accomplish a specific task in your CI pipeline, it could be to compile our code, run integration tests or deploy our application. However, a true CI includes all those 3 steps and chains them together in a sequential or parallel manner. This is what we call a “Pipeline”. It is possible to achieve chaining by using the freestyle jobs but at end of the day, it’s not very convenient for a single Application. The pipeline would consist of a bunch of freestyle jobs connected in an upstream-downstream fashion. Communicating amongst these jobs for eg: sharing variables, custom statuses can be a nightmare. All these problems go away with Pipeline Jobs! Version Control your job configurations: As previously mentioned, the Jenkinsfile is just a groovy script thus, it can be stored, edited and version controlled along with the rest of the application code! Grand theft auto 5. Before we go ahead and start writing our Jenkinsfile, let’s visualize the steps we need to build and publish this application. } Let’s break it break it down here: Line#1: The node keyword is used to select the build agent Line 4, 5, 9: The stage keyword is used to define the stages in our build Dynamic Build Versions One of the things that we have fast-forwarded is “tokenizing” image versions with the Jenkins build number. Jenkins exposes BUILD_NUMBER as an environment variable amongst others ? Each new build, auto-increments the version. To support this, the docker-compose.integration.yml file is also “tokenized” in the same fashion. Stage Logs Running Tests and Publishing Reports in Jenkins We have successfully executed tests in the previous build. One of the benefits of using Jenkins is the post-build report publishing feature which helps us collate our test results and publish them as HTML reports! We will be using the to publish reports but, before that, ther e are two problems we need to address. Problem 1: The container stores the results of the tests that it executes within itself.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |