DevOps, Day - 26
As we previously used a Jenkins Freestyle project, today we will be selecting a Jenkins Pipeline instead...
So first let's see what Jenkins's declarative pipeline means..!
Pipeline:
- A Pipeline is a set of connected tasks, like steps in a recipe, that automatically build and deploy your software.
Declarative:
- Declarative is the easy way to list those steps in plain language, making it clear and simple to understand.
Scripted:
- Scripted is a more technical way to list the steps, like writing a detailed plan in a specific coding language (Groovy).
Why You Should Have A Pipeline?
A Jenkins Pipeline is like a recipe for building and deploying software. It's written in a file (called a Jenkinsfile) that can be stored with your project's code.
When you create a Jenkinsfile and store it with your code, it brings several advantages:
Automated Builds: It automatically sets up the process for building your software whenever changes are made to your code.
Code Review: You can review and improve the build process, just like you review and improve your code.
Pipeline Syntax
pipeline {
agent any
stages {
stage('Build') {
steps {
sh 'echo "Building the software"'
// Add your actual build commands here
}
}
stage('Test') {
steps {
sh 'echo "Testing the software"'
// Add your actual test commands here
}
}
stage('Deploy') {
steps {
sh 'echo "Deploying the software"'
// Add your actual deployment commands here
}
}
}
}
Let's Complete the Hello World Example, by following the steps given in this documentation --> Link
Step 1: Click on http://localhost:8080
Step 2: Click on my blog link to install Jenkins --> link
Step 3: Create a New Jenkins Pipeline
Click on "New Item" on the Jenkins homepage.
Enter a name for your pipeline (e.g., "HelloWorld") --> Choose "Pipeline" as the project type --> Click "OK."
Step 4: Configure the Pipeline
In the pipeline configuration, scroll down to the "Pipeline" section.
Select the "Pipeline script" option.
Copy and paste the example pipeline code from the Jenkins official website into the script block.
Here's the code from the official example:
pipeline {
agent any
stages {
stage('Hello') {
steps {
echo 'Hello, world!'
}
}
}
}
Step 5: After saving, click --> Build Now
Step 6: Click on #1
Step 7: Here is the output...
Thank you so much for reading.
Follow me on LinkedIn to see interesting posts like this : )
Subscribe to my newsletter
Read articles from Vrishni Shree V B directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by
Vrishni Shree V B
Vrishni Shree V B
๐ป Python | Docker | Jenkins | Networking | Git | Linux ๐ป Passionate about leveraging technology to drive efficiency and deliver innovative solutions. Proficient in Python development, Docker containerization, Jenkins automation, computer networking, Git version control, and Linux administration. Skilled in collaborating with diverse teams to deliver high-quality software products. Proficient in AWS EC2 instance management and deployment. Seeking new opportunities to apply my expertise and contribute to impactful projects. Let's connect and explore how we can work together! Inter-personal Skills: Communication, Adaptability, Emotional intelligence, Active listening, Collaboration. Happy To Connect๐๐ Feel free to reach me out๐@ --> vrishnishreevb531@gmail.com ๐ฌ