๐Ÿš€ Week 6 โ€“ Jenkins (CI/CD) Challenge

This weekโ€™s challenge was all about Jenkins, one of the most popular CI/CD tools.
I worked on real-world tasks like creating pipelines, multi-branch jobs, configuring agents, RBAC, shared libraries, vulnerability scanning with Trivy, email notifications, and debugging pipelines.

The goal was to simulate real DevOps scenarios and prepare for interviews by gaining hands-on experience.


๐Ÿ”น Task 1: Create a Jenkins Pipeline Job for CI/CD

Steps:

  1. Created a new Pipeline Job in Jenkins.

  2. Wrote a Jenkinsfile with three stages: Build, Test, Deploy.

pipeline {
    agent any
    stages {
        stage('Build') {
            steps {
                echo 'Building the application...'
                sh 'docker build -t sample-app:v1.0 .'
            }
        }
        stage('Test') {
            steps {
                echo 'Running tests...'
                sh 'docker run --rm sample-app:v1.0 npm test'
            }
        }
        stage('Deploy') {
            steps {
                echo 'Deploying application...'
                sh 'docker run -d -p 8080:80 sample-app:v1.0'
            }
        }
    }
}

โœ… Verified with docker ps that container was running.

Interview Takeaways:

  • Declarative pipelines are easier to maintain than scripted ones.

  • Breaking into stages makes it easier to troubleshoot failures.


๐Ÿ”น Task 2: Multi-Branch Pipeline for Microservices

Steps:

  1. Created a Multi-Branch Pipeline Job.

  2. Configured Jenkins to scan GitHub repo branches.

  3. Each microservice had its own Jenkinsfile with stages: Checkout โ†’ Build โ†’ Test โ†’ Deploy.

  4. Used parallel stages to test multiple services at once.

parallel {
    stage('Service-A Tests') { steps { sh './test-service-a.sh' } }
    stage('Service-B Tests') { steps { sh './test-service-b.sh' } }
}

โœ… Simulated feature branch merge with PR workflow.

Interview Takeaways:

  • Multi-branch pipelines automatically handle new branches.

  • Challenge: Managing dependency between services when merging branches.


๐Ÿ”น Task 3: Configure & Scale Jenkins Agents

Steps:

  1. Added two agents:

    • Linux (Docker container)

    • Windows (VM)

  2. Gave them labels like linux, windows.

  3. Updated Jenkinsfile to run jobs on specific agents:

stage('Build on Linux') {
    agent { label 'linux' }
    steps { sh 'make build' }
}

โœ… Ran jobs in parallel across agents โ†’ faster builds.

Interview Takeaways:

  • Distributed agents increase scalability & reliability.

  • Correct job assignment requires proper labels.


๐Ÿ”น Task 4: Implement RBAC

Steps:

  1. Installed Role Strategy Plugin.

  2. Created roles:

    • Admin โ†’ Full access

    • Developer โ†’ Build & view jobs

    • Tester โ†’ Only read access & trigger jobs

  3. Created test accounts and verified access.

โœ… Developers couldnโ€™t change configs, testers couldnโ€™t delete jobs.

Interview Takeaways:

  • RBAC prevents unauthorized access.

  • Weak RBAC can lead to pipeline tampering or security breaches.


๐Ÿ”น Task 5: Jenkins Shared Library

Steps:

  1. Created a Git repo jenkins-shared-lib.

  2. Added reusable vars/notify.groovy function:

def call(String message) {
    echo "Notification: ${message}"
}
  1. Used it in pipeline:
@Library('jenkins-shared-lib') _
pipeline {
    stages {
        stage('Notify') {
            steps {
                notify("Build completed successfully")
            }
        }
    }
}

โœ… Avoided code duplication across pipelines.

Interview Takeaways:

  • Shared libraries improve maintainability.

  • Ideal for tasks like notifications, deployment scripts, code quality checks.


๐Ÿ”น Task 6: Vulnerability Scanning with Trivy

Steps:

  1. Installed Trivy inside Jenkins agent.

  2. Added scan stage:

stage('Vulnerability Scan') {
    steps {
        sh 'trivy image sample-app:v1.0'
    }
}
  1. Configured build to fail if critical vulnerabilities found.

โœ… Got scan results and patched vulnerable dependencies.

Interview Takeaways:

  • Automated scanning ensures security in CI/CD.

  • Trivy detects CVEs in images before deployment.


๐Ÿ”น Task 7: Dynamic Pipeline Parameterization

Steps:

Added runtime parameters:

pipeline {
    agent any
    parameters {
        string(name: 'TARGET_ENV', defaultValue: 'staging')
        string(name: 'APP_VERSION', defaultValue: '1.0.0')
    }
    stages {
        stage('Deploy') {
            steps {
                echo "Deploying version ${params.APP_VERSION} to ${params.TARGET_ENV}"
            }
        }
    }
}

โœ… Deployed same pipeline to staging & production with different values.

Interview Takeaways:

  • Parameterization makes pipelines flexible.

  • Useful in multi-env deployments (Dev, QA, Prod).


๐Ÿ”น Task 8: Email Notifications

Steps:

  1. Configured SMTP in Jenkins.

  2. Added emailext stage:

stage('Notify') {
    steps {
        emailext (
            subject: "Build Notification: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
            body: "Check build logs at: ${env.BUILD_URL}",
            to: "team@example.com"
        )
    }
}

โœ… Team received build notifications.

Interview Takeaways:

  • Keeps teams updated automatically.

  • Troubleshoot issues via SMTP logs & Jenkins email plugin config.


๐Ÿ”น Task 9: Troubleshooting, Monitoring & Debugging

Steps:

  1. Simulated failure by breaking a command in Jenkinsfile.

  2. Debugged with:

    • Jenkins console logs

    • docker logs <container_id>

    • Replay feature for quick fixes.

  3. Added debug statements:

echo "Environment: ${env.BUILD_NUMBER}"

โœ… Identified errors quickly.

Interview Takeaways:

  • Debugging = console logs + replay + echo statements.

  • Monitoring can be done with plugins (Prometheus, Monitoring plugin).


๐ŸŒŸ Key Learnings

  • Jenkins pipelines make automation repeatable & reliable.

  • Multi-branch pipelines simplify microservices CI/CD.

  • Agents help in scaling workloads across environments.

  • RBAC secures CI/CD environments.

  • Shared libraries & parameterization โ†’ reusability & flexibility.

  • Security scanning with Trivy is essential in DevOps pipelines.

  • Email notifications + monitoring keep teams informed.


๐Ÿ’ฌ This hands-on week gave me real-world exposure to Jenkins CI/CD pipelines โ€” from basics to advanced use cases like multi-branch pipelines, RBAC, shared libraries, vulnerability scanning, and troubleshooting.
Now I feel more confident in setting up production-grade CI/CD pipelines that are scalable, secure, and flexible. ๐Ÿš€


๐Ÿ“ค Connect With Me

๐Ÿ”—LinkedIn: linkedin.com/in/vaishnavi-tandekar ๐Ÿ“– Blog Series: hashnode.com/@VaishnaviTandekar
๐Ÿ’ป GitHub Repo: 90DaysOfDevOps


๐Ÿ”– Hashtags:

#90DaysOfDevOps #Jenkins #CI/CD #DevOps #Automation #Microservices #CloudNative #InterviewPrep


1
Subscribe to my newsletter

Read articles from Vaishnavi Tandekar directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Vaishnavi Tandekar
Vaishnavi Tandekar

Hey there! Iโ€™m Vaishnavi ๐Ÿ‘‹ Learning DevOps step by step ๐Ÿ› ๏ธ Writing what I learn so no one learns alone โœจ