Jenkins – Chapter 1: Getting Started with Jenkins, Your Gateway to Continuous Integration

Jenkins is the most widely used open-source automation server that facilitates Continuous Integration and Continuous Deployment (CI/CD) in the world of software development. Whether you’re a seasoned developer or just starting your journey, Jenkins can be your best friend when it comes to automating repetitive tasks in your development pipeline. In this post, we’ll walk you through the basics of getting started with Jenkins.

Installation

Jenkins is basically a Java application, however depending on the OS install steps can be found at official doc: https://www.jenkins.io/doc/book/installing 

Start Jenkins

Depending on how it was installed, use appropriate command to start Jenkins. On the back end, it runs `java -jar jenkins.war` If you installed it via OS specific packages on Linux as I did, use systemctl command to start it.
sudo systemctl start jenkins.service
sudo systemctl status jenkins

Access Jenkins admin

Jenkins by default runs on port 8080. So, open any web browser and go to http://IP_ADDRESS:8080 to access the Jenkins web interface.
Just make sure that firewall allows the port if enabled.

Unlock Jenkins

You will need to retrieve the initial administrator password from the Jenkins server and follow the on-screen instructions to complete the setup.

First Run

After unlocking Jenkins, you’ll be guided through an initial setup process where you can install recommended plugins.

Follow the rest of the screens

Just basic stuff like admin user setup and url customisation.

Hello World Pipeline

Once initial setup is complete you’ll be presented the Jenkins Dashboard.

Click on New Item >> Enter an item name of your choice >> Choose Pipeline and click OK

Scroll down and from Definition drop down select Pipeline script.

From try sample Pipeline drop down select Hello World and click Save

Run Build Now

View Logs,

Basic Pipeline

One of the fundamental features of Jenkins is the ability to create pipelines to automate your build and deployment processes. Here’s a quick example of a simple pipeline:
pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                sh 'echo "Building the project"'
            }
        }
        stage('Test') {
            steps {
                sh 'echo "Running tests"'
            }
        }
        stage('Deploy') {
            steps {
                sh 'echo "Deploying the application"'
            }
        }
    }
}
This basic pipeline consists of three stages: Build, Test, and Deploy. You can customize each stage to execute specific commands or scripts for your project.

Declarative and Scripted Approaches

Jenkins offers two main approaches for defining pipelines: declarative and scripted.

Declarative Pipeline

  • Declarative pipelines use a simpler, more structured syntax.
  • They are great for beginners and those who want to quickly define pipelines without delving into complex scripting.

Scripted Pipeline

  • Scripted pipelines are written in Groovy and provide more flexibility and power.
  • They are suitable for advanced users who need fine-grained control over their pipeline logic.
You can choose the approach that best suits your needs and gradually transition between them as your requirements come up.
Congratulations, you’ve taken your first steps into the world of Jenkins! As you become more comfortable with Jenkins, you can explore its extensive plugin ecosystem and further customize your automation processes to meet the specific needs of your projects. Happy automating!

Leave a Reply

Your email address will not be published. Required fields are marked *

Your technology transformation partner

© 2023 biskitAI

Scroll to Top