Jenkins Pipeline: A Step-by-Step Guide
Tue, 11 Jun 2024
Follow the stories of academics and their research expeditions
Jenkins is a popular open-source automation server used to build, test, and deploy applications. In this guide, we will walk you through the process of downloading, installing, and configuring Jenkins Pipeline. We will also cover how to configure plugins, global settings, credentials, and GitHub integration. Let's get started!
Go to the Jenkins official website.
Click on the "Download" button. Choose your operating system (Windows, macOS, Linux) and download the appropriate installer.
For Windows: Double-click the downloaded .exe
file and follow the installation wizard.
For macOS: Open the downloaded .pkg
file and follow the installation instructions.
For Linux: Use the package manager to install Jenkins. For example, on Ubuntu:
sudo apt update
sudo apt install jenkins
Once installed, start the Jenkins service.
On Windows: Jenkins usually starts automatically. If not, find Jenkins in the Services app and start it.
On macOS and Linux: Use the command:
sudo systemctl start jenkins
Open a web browser and navigate to http://localhost:8080
. You will see the Jenkins unlock screen.
Locate the initial admin password. This is usually found in a file on your system.
For Windows: Check the C:\Program Files (x86)\Jenkins\secrets\initialAdminPassword
file.
For macOS and Linux: Check the /var/lib/jenkins/secrets/initialAdminPassword
file.
Copy the password from the file and paste it into the Jenkins unlock screen. Click "Continue."
Jenkins will prompt you to install suggested plugins. Click on "Install suggested plugins." Jenkins will start installing the necessary plugins. This may take a few minutes.
Once the plugins are installed, you will be asked to create your first admin user. Fill in the required details and click "Save and Finish."
Jenkins will ask you to confirm the Jenkins URL. Leave it as default (http://localhost:8080
) and click "Save and Finish."
From the Jenkins dashboard, click on "Manage Jenkins."
Click on "Manage Plugins." Go to the "Available" tab to see the list of available plugins. Use the search bar to find plugins you need (e.g., "Pipeline," "GitHub"). Select the plugins and click "Install without restart."
Go to "Manage Jenkins" -> "Global Tool configuration." Configure tools such as JDK, Git, and Maven by specifying their locations. Click "Save" when done.
From the Jenkins dashboard, click on "Manage Jenkins" -> "Manage Credentials."
Select the domain (e.g., Global) where you want to add credentials. Click on "Add Credentials." Enter the required information (e.g., username, password, secret text) and click "OK."
Follow the same steps as in Step 8, but choose "GitHub" as the credential type. Enter your GitHub username and personal access token. Click "OK."
From the Jenkins dashboard, click on "New Item." Enter a name for your job, select "Pipeline," and click "OK."
In the job configuration page, scroll down to the "Pipeline" section. Select "Pipeline script from SCM" if you want to use a script from your version control system. Choose "Git" as the SCM and enter your repository URL. Select the credentials you added earlier.
If you choose to write the script directly in Jenkins, select "Pipeline script" and enter your script in the text area. Here's an example:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
stage('Test') {
steps {
echo 'Testing...'
}
}
stage('Deploy') {
steps {
echo 'Deploying...'
}
}
}
}
Click "Save."
Go to the job dashboard and click on "Build Now." Jenkins will start running your pipeline. You can view the progress and logs in the console output.
Tue, 11 Jun 2024
Sun, 26 May 2024
Leave a comment