What can Jenkins do?

jenkins logo.jpg

It has been a pretty long while since I have last written an article or even dabbled into programming due to my final exams. Now completed! Before I started my exams, I was to perform some tasks on Jenkins which I had to put on hold because I wasn't getting a headway.

So why all this stress with Jenkins? It is because of what Jenkins can do!

What is Jenkins?

Jenkins is an open-source tool, written in Java for the automation of CI/CD pipelines. It is used for the building and testing of software projects and for the continuous integration of changes to project by developers.

Jenkins Installation

This gave me a run for my money. At first, it seemed quite hard. This was because I tried to have it installed on my WSL (Windows Subsystem for Linux) running Ubuntu 20.04. This made me run into some challenges; for instance, I was having peculiar issues starting the jenkins service using sudo service jenkins start and most of the suggestions I saw online were for me to use sudo systemctl start jenkins. I figured this is most likely due to WSL not running a fully-fledged Linux kernel. However, I realised much later that it wasn't as hard or complicated as I initially envisioned it.

I decided to run the Jenkins installation on a cloud provider. I used Google Cloud Platform to create a VM instance running an Ubuntu 20.04 image. If you'd like to do the same check here. Otherwise, you can perform the commands on your local server if you have "systemd" installed to perform "systemctl" commands. As I mentioned earlier, you would need this utility to make Jenkins run and be online to install plugins, extensibles, perform continuous integrations etc.

Java Installation

  • First things first! Installation of Java. This is due to Jenkins being a Java application. (you would only be able to do this if you are running the commands as root or a user with sudo privileges).

     $ sudo apt update
     $ sudo apt install openjdk-11-jdk
    
  • Once installation is complete, verify it by checking the Java version:

    $ java -version
    

    The Output should give a result similar to something like this:

//Output
openjdk version "11.0.10" 2021-01-19
OpenJDK Runtime Environment (build 11.0.10+9-Ubuntu-0ubuntu1.20.04)
OpenJDK 64-Bit Server VM (build 11.0.10+9-Ubuntu-0ubuntu1.20.04, mixed mode, sharing)

Installation and starting Jenkins

  • Now we can install Jenkins by adding the repository key:
    $ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key | sudo apt-key add -
    
    After the key is added, You'd get an OK. If you don't, run the commands before and after the pipe | separately to get an OK.
$ wget -q -O - https://pkg.jenkins.io/debian-stable/jenkins.io.key 
$ sudo apt-key add -
  • Next, we append the Debian package repository address to the server’s sources.list:
$ sudo sh -c 'echo deb http://pkg.jenkins.io/debian-stable binary/ > /etc/apt/sources.list.d/jenkins.list'
  • Next is to run an update in order for apt to use the new repository
    $ sudo apt update
    
  • And now we can install Jenkins along with its dependencies, using:

    $ sudo apt install jenkins
    
  • We can start Jenkins using:

    $ sudo systemctl start jenkins
    
  • To check the status:

    sudo systemctl status jenkins
    

    The output shown:

    //output
    jenkins.service - LSB: Start Jenkins at boot time
       Loaded: loaded (/etc/init.d/jenkins; generated)
       Active: active (exited) since Tue 2021-03-23 07:49:49 UTC; 24h ago
         Docs: man:systemd-sysv-generator(8)
        Tasks: 0 (limit: 2374)
       Memory: 0B
       CGroup: /system.slice/jenkins.service
    

    Opening firewall

  • To enable the firewall, set up ufw. NOTE: You need to allow ssh before enabling ufw or else you will be locked out of your remote server. THIS IS VERY IMPORTANT! To allow ssh:

$ sudo ufw allow ssh
  • By default, Jenkins runs on port 8080. So we would have to open that port also using:

    $ sudo ufw allow 8080
    
  • Then you can now enable the UFW firewall using:

$ sudo ufw enable
  • When you check ufw's status using:
$ sudo ufw status

You get an output of:

Status: active

To                         Action      From
--                         ------      ----
22/tcp                     ALLOW       Anywhere                  
8080/tcp                   ALLOW       Anywhere                  
22/tcp (v6)                ALLOW       Anywhere (v6)             
8080/tcp (v6)              ALLOW       Anywhere (v6)

Setting up Jenkins

  • To set up installation, visit Jenkins on its default port, 8080, using the server domain name or IP address: http://your_server_ip_or_domain:8080 To get the server IP (for local Jenkins deployment) you can do this by using:
    $ ifconfig
    
    Output is shown below; the highlighted part is the IP to be used on your URL browser like this,192.168.33.194:8080.

ifconfig2.jpg

The first word, eth0 might be enp0s3 and that is fine. It's the difference between the new and old naming scheme of the interface. If you used an instance to get a remote server like me, you can get your external IP here:

jenkins1.jpg

On your URL browser, type 35.224.19.181:8080. (URL should be different for you)

You are taken to this page below which begins the Jenkins setup.

Jenkins setup

unlock jenkins.jpg

  • To get password:
    $ sudo cat /var/lib/jenkins/secrets/initialAdminPassword
    
    Click continue to be taken to the next page. Here you are presented with the option of installing suggested plugins or selecting specific plugins. I suggest you choose "Install suggested plugins" as this would install the basic/recommended plugins. You can choose to add more later on.

jenkins customize.jpg

The installation of the necessary plugin required by Jenkins will commence.

jenkins started.jpg

Once completed, you would be taken to the next section where you will be required to create an admin user. Fill the spaces with the required details. "Save and Continue".

jenkins admin user.jpg

The next step will populate the default URL for your Jenkin’s instance. No action is required, simply click "Save and Finish".

jenkins instant config.jpg

And Booooom! your Jenkins is ready! Click the "Start Using Jenkins".

jenkins ready.jpg

Here you can see your dashboard where you can now fully enjoy Jenkins.

jenkins homepage.jpg

Do you want to know what Jenkins can do? we would need to first mention its features.

Features of Jenkins

jenkins feature.jpg

  • Easy Installation: Jenkins has an easy installation process. It is a self-contained Java-based program, able to run with packages for Window, Mac OS, and Unix-like operational systems.

  • Continuous Integration (CI): Jenkins is able to handle, orchestrate and, accelerate the entire software development life cycle (SDLC) by automating it.

  • Continuous Delivery (CD): Jenkins manages and controls software delivery processes throughout the entire lifecycle, including build, document, test, package, stage, deployment, static code analysis and much more.

  • Easy Configuration: Jenkins allows for an easy configuration for the setup environment in the user interface. it is possible to customize the user interface based on preference.

  • Distributed & Extensible Plugins: Jenkins is easily extensible with the use of third-party plugins over 400.

What can Jenkins do?

  • Jenkins prevent engineers from shipping broken code into a production environment. In cases where a build is broken, it sends a warning to developers (if configured) and prevents the automated merging of changes.

  • It is noteworthy to mention Jenkins is able to turn a 3-day deployment process into, say, a 3-hour process and even shorter due to the ability to update version control systems and decrease code review time. Even better, you can configure it to merge itself.

  • Jenkins can deploy code to staging environment automatically (Continuous Delivery) if all test written for the same within a specific feature or release branch is green/blue i.e. all build stages pass. When Jenkins is configured to automatically deploy code to production, it is known as Continuous Deployment.

  • Jenkins is one automation tool that prevents developers from pointing fingers at one another as it creates transparency and accountability in team members.

  • One major thing I love Jenkins for is the fact that it lowers the effort of repeated coding, this can be done by wrapping up scripts as a Jenkins job i.e. it is great for automation.

Conclusion

Thanks for sticking all the way to the end! Here is a brief summary of what you have learnt:

  • Java installation.
  • Jenkins Installation and set up.
  • Features of Jenkins.
  • What Jenkins can do.

Want to learn more? check: