📖 Scenario: You work in a team that uses Jenkins for continuous integration. Your manager wants you to compare Jenkins with CircleCI to understand the differences and benefits.
🎯 Goal: Create a simple Jenkins pipeline script that defines a basic build job. Then, add a configuration variable to simulate a build environment. Next, write the core logic to run a build step. Finally, output the build status to compare with CircleCI's process.
📋 What You'll Learn
Create a Jenkins pipeline script with a pipeline block
Add an environment variable BUILD_ENV with value staging
Use a stage named Build with a steps block
Print the build environment and a success message
💡 Why This Matters
🌍 Real World
Teams use Jenkins or CircleCI to automate building and testing software. Understanding both helps choose the right tool.
💼 Career
Knowing how to write and configure Jenkins pipelines is a key skill for DevOps engineers and software developers working with CI/CD.
Progress0 / 4 steps
1
Create a basic Jenkins pipeline
Write a Jenkins pipeline script starting with pipeline { and include an empty agent any block.
Jenkins
Hint
Start with pipeline { and add agent any inside.
2
Add environment variable configuration
Inside the pipeline block, add an environment block with a variable BUILD_ENV set to staging.
Jenkins
Hint
Use environment { BUILD_ENV = 'staging' } inside the pipeline.
3
Add a build stage with steps
Add a stage named Build inside the pipeline block. Inside it, add a steps block with a sh command that echoes Building in $BUILD_ENV environment.
Jenkins
Hint
Use stages { stage('Build') { steps { sh 'echo ...' } } } inside the pipeline.
4
Print build success message
Inside the Build stage's steps, add another sh command that echoes Build completed successfully.
Jenkins
Hint
Add sh 'echo Build completed successfully' after the first echo.
Practice
(1/5)
1. Which statement best describes Jenkins compared to CircleCI?
easy
A. Jenkins is self-hosted and offers full control over the environment.
B. Jenkins is only cloud-based and easy to start with.
C. Jenkins does not support automation of builds and tests.
D. Jenkins requires no setup or management.
Solution
Step 1: Understand Jenkins hosting model
Jenkins is known for being self-hosted, meaning you install and manage it yourself.
Step 2: Compare with CircleCI
CircleCI is mostly cloud-based and easier to start with, unlike Jenkins which requires more setup.
Final Answer:
Jenkins is self-hosted and offers full control over the environment. -> Option A