The course is part of this learning path
This training course introduces you to Jenkins, a popular open source tool used to perform Continuous Integration and Continuous Delivery.
We spend time early on reviewing the key Jenkins features and associated terminology. We then take you through a deep dive in configuring Jenkins to perform automated builds using the Jenkins web administration console in hands on demonstrations, ensuring that you become familiarised with Jenkins and how to administer it. We’ll demonstrate features such as:
- Installing and setting up Jenkins
- Creating and configuring pipelines manually
- Creating and configuring pipelines using a Jenkinsfile
- Configuring Jenkins pipelines using the Blue Ocean interface
- Defining build execution environments using docker containers
- Triggering build pipelines, manually and automatically
- Navigating downstream and upstream build projects
- Connecting to version control repositories such as GitHub
- Setting up build pipelines for Java based projects using Gradle
- Recording artifacts and test results
- Setting up and scaling out Jenkins with multiple build agents and executors using SSH
What you'll learn:
- The basic principles of build automation as implemented within Jenkins and how should be a applied to manage and maintain building, testing, and deploying your own enterprise software projects
- How to install, setup, and configure Jenkins pipelines
- The key differences between Jenkins declarative and scripted pipelines
- How to manage build artifacts and test results
- How to scale out Jenkins using Master and Build Agent setups using SSH
- The benefits of codifying pipeline build instructions using a Jenkinsfile
- How to leverage Docker containers within a Jenkins pipeline to provide additional build isolation and flexibility
- How to install and use the newer more modern pipeline centric BlueOcean user interface
- How to integrate and leverage 3rd party build tools like Gradle, Maven, Yarn, Webpack, and many more within a Jenkins pipeline
This training course provides many hands on demonstrations where you will observe first hand how to use Jenkins to build and release different types of software projects, for example:
- Building a back end application developed using Java, Gradle, and Docker, requiring Jenkins to compile the source code, packaging it into a WebArchive file, and then finally releasing it into a Tomcat based Docker image complete with Splunk based instrumentation for logging and monitoring
- A basic understanding of CICD, or Continuous Integration and Continuous Delivery
- A basic understanding of software development and the software development life cycle
- A basic understanding of version control and associated workflows
- Software Build and Release Engineers
- Software Developers
- DevOps Practitioners
- [Instructor] Okay, welcome back! In this next demonstration we're going to use Docker and DockerCompose to spin up a locally hosted version of Jenkins, but before we do so let's consider some of the reasons why we'd want to take this approach.
Well, there are times where you might be prototyping and trying to understand the best configuration to use for your Jenkins set-up. By leveraging Docker and running Jenkins locally you can prototype very easily and this is a really great way to actually do this and luckily Jenkins provides an official Docker image for doing this. If we open up the jenkins.io homepage and click on the download link if we scroll down we can see that Jenkins provides a Docker image, clicking on it will take us into Docker hub. Here we can see the official Jenkins Docker image. So if you wanted to pull this image down you would simply run docker pull jenkins/jenkins.
In this demonstration we'll actually use the Jenkins LTS version or the Long Term Support version. So, let's jump into our terminal and create a directory jenkins-docker. We'll jump into that directory and we'll open up visual code and what we're going to do is create a dockercompose.yml file. Click a new file, we'll call it docker-compose which is the convention .yml. So I'll now post in some pre-formatted DockerCompose configuration. We'll go through some of these attributes, so here we're specifying that we're using version 3.5 of the DockerCompose syntax. Under services we're specifying that we're going to spin up a jenkins container and that it's going to have the container name: jenkins-docker. We're specifying the official docker image for jenkins in this case the LTS version and that we're binding port 8080 to the 8080 port on the jenkins container. We then need to set-up the actual network that this container will be attached to.
Jumping back into our terminal we'll run the command docker network list. This lists all of the existing docker networks that we have available. Here I'll choose the devnetwork. We'll jump back into our configuration and we'll specify under the networks that we're going to use the devnetwork and that the name is devnetwork. Finally, back with the now jenkins container we need to specify that we are attaching to this particular network. Okay, that looks good. We'll save it. We'll jump back into the terminal, do a directory listing. This is the docker-compose.yml file that we just created if we cat out the contents. Looks good. So we'll test the configuration to make sure that the syntax is correct. We do so by running docker-compose config and if it prints out the configuration without any errors than we know we're good which it has done here.
So at this stage we can actually launch it. Now typically you would do this by running docker-compose up and pressing enter, but I'm going to do so by adding -d parameter to detach the launching process, but I'll also add in the docker-compose logs command with the parameter f to follow. So, we'll press enter and this begins the provisioning process. So here we can see our jenkins container is now launching. We can see that the initial admin password is printed out. So we'll take a copy of this. Okay, so it looks like the installation has completed and that the container has been provisioned as per the info statement: Jenkins is fully up and running. So I can control c out of this. You can ignore the error at the end that was us just exiting out of the DockerCompose log command.
Okay, the next thing we'll do is we'll take a quick look at the running containers by running the docker ps command. Here we can see that our jenkins container is still up and running. Now if we actually wanted to jump into the jenkins-docker container, we can do so by running the docker exec -it name of the container in this case jenkins-docker and running the bash command, pressing enter we find we are now entered into the docker-jenkins host. So we run control l. We clear the terminal, again we can do a directory listing. We can jump into the /var/jenkins_home directory, do another directory listing. You'll notice here we have the secrets directory. We can navigate into that directory listing again and if we cat out the initial admin password we can see the password that we need to complete the installation.
Okay, let's exit back to the terminal. Now another approach to actually get this initial admin password is instead of running the bash command and navigating manually what we can do is actually just cat it out cat /var/jenkins_home/secrets/initialAdminPassword and again we get the same password value. Okay, so again let's run docker ps and you can see that we're exposing port 8080, so we'll jump into our browser and we'll go to localhost port 8080, enter. So we need to complete the installation by unlocking Jenkins, so we need the initial admin password, posting it, continue. Here we install the suggested plug-ins. This typically takes two to five minutes to complete depending on the speed of the internet connection that the local host is connected too. Occasionally a plug-in may fail to install as can be seen here with the Pipline plug-in. This may be caused by a disruption in the internet connection, in this particular case we can simply click the retry button for it to be completed.
Okay, we'll now create the first admin user in this case we'll call it Admin, specifying a password, full name again this will just be me and specifying my Cloud Academy email address. Clicking save and continue, under Instance Configuration this time you'll see that the host is localhost so again we'll accept the defaults and click save and finish and we're up and running. So this time we have Jenkins running locally using a docker container running on our local work station. Perfect prototyping and testing different configurations.
About the Author
Jeremy is the DevOps Content Lead at Cloud Academy where he specializes in developing technical training documentation for DevOps.
He has a strong background in software engineering, and has been coding with various languages, frameworks, and systems for the past 20+ years. In recent times, Jeremy has been focused on DevOps, Cloud, Security, and Machine Learning.
Jeremy holds professional certifications for both the AWS and GCP cloud platforms.