Start course
1h 18m

In this course, we will learn the concepts of microservice and spring framework with a focus on Cloud.

Learning Objectives

  • Learn about Cloud

Intended Audience

  • Beginner Java developers
  • Java developers interested in learning how to Build and Deploy RESTful Web Services
  • Java Developers who want to develop web applications using the Spring framework
  • Java Developers who want to develop web applications with microservices
  • Java Developers who wish to develop Spring Boot Microservices with Spring Cloud


  • Basic Java knowledge

Jenkins. Hello dear friends. In this lesson, we will talk about Jenkins. Jenkins is a software platform that supports continuous integration and continuous delivery. It's used to automate software testing, building delivery, and deployment. I plan to provide two examples with Jenkins  to properly explain it. First, let's open the Jenkins dashboard. We need to install some extensions. Click 'Manage Jenkins'. Click 'Manage Plugins'. Click 'Available Plugins'. Write docker into the search box. Here, select Docker API plugin. Docker Commons plugin. Docker Pipeline, Docker plugin, and docker-build-step. Press 'Install without restart'. It will redirect you to a new page. Here, tick the box, restart Jenkins when installation is complete and no jobs are running. This is going to take a while. Now we will create a job to build the source and generate a new var file each time we issue a commit. I've created a GitHub repository and pushed the code there.

As you see here, open Jenkins dashboard, click 'New item', write a name, select 'Freestyle project', and click 'OK'. Under Source Code Management, select 'Git'. Write down the Git repository here. You can copy and paste it easily. There is no need to provide credentials or simply readers. Empty branch specifier field. Under Build Triggers, select poll SCM and write into the box star symbols. It means that it checks the GitHub repository once per minute to see if a new commit has been made or not. If there is a new commit, it will trigger the job. Let be one space character between star characters to separate them. Select Maven Version. Write clean package as the goal. Okay, 'Save'. Now, the only thing we need to do is make some changes to our application. Give it a commit and push it to GitHub. Okay, I made a basic change. Let's give a commit and push the changes to our GitHub repository. Open the Jenkins dashboard. Please wait. As you can see, it began a new build and completed the task.

Okay, now let's move a step further. We will write a pipeline to generate a Docker image from GitHub repository and push it to Docker Hub. We've created a Docker Hub account. You can get it easily. It has a free usage option as well. Before we begin the pipeline, we will generate a secret key that will allow Jenkins to connect to Docker Hub. Click 'User Title', select 'Account Settings'. Click 'Security'. Click 'New Access Token'. Write a random text to the access token description box. Okay, it generates an access token. Copy the token. Open the Jenkins dashboard. Click 'Manage Jenkins'. Click 'Manage Credentials'. Click 'System'. Click 'Global' and click 'Add Credentials'. Here, write your Docker username as the username and paste the token into the password field. Write an ID in a description. Okay, press 'Create' button. Open Jenkins dashboard. Click 'New Item'. Write a suitable name and select pipeline.

Click 'OK'. We will define this job using a pipeline script. In the tools part, I define maven. We will use it to build the Docker Image. In the environment part, I define the Docker Hub credential that I've just created. The body of the script consists of some stages. In the first stage, we check out the application code from the GitHub repository and create a package from it. In the next stage, we build the Docker image locally. And after that, we log into the Docker Hub repository. Then following that, we will add tag info to our Docker image to push it without error. Finally, we push the image to Docker Hub. After all, we will log out of Docker Hub. Okay, let's build it. Okay, so just so you know, it's going to take a while. All right, as you can see, the task was successfully completed. Let's check our Docker Hub account. Okay, as you can see here, a new image was created. All right, my friends, that's all for now. I'll see you in the next lesson.


About the Author
Learning Paths

OAK Academy is made up of tech experts who have been in the sector for years and years and are deeply rooted in the tech world. They specialize in critical areas like cybersecurity, coding, IT, game development, app monetization, and mobile development.