CICD Interview 101

No comments

 

CI/CD Senior Engineer Interview Questions (Jenkins, Python, Maven, Jenkinsfile)

Section 1: Jenkins (Core & Advanced)

  1. What is Jenkins and how does it work?

    • Hint: Master-slave architecture

    • Answer: Jenkins is an open-source automation server used for CI/CD. It uses master-slave architecture to distribute build tasks across multiple machines.

  2. Explain Jenkins pipeline.

    • Hint: Declarative vs Scripted

    • Answer: Jenkins Pipeline is a suite of plugins that supports implementing and integrating continuous delivery pipelines. It supports Declarative and Scripted syntaxes.

  3. Difference between Declarative and Scripted Pipeline?

    • Hint: Syntax structure

    • Answer: Declarative pipeline uses a predefined structure, easier for beginners. Scripted pipeline is Groovy-based and offers more control and flexibility.

  4. How do you handle parallel stages in Jenkins?

    • Hint: parallel keyword

    • Answer: Use the parallel directive inside a stage to run tasks concurrently.

  5. What is the purpose of agent in Jenkinsfile?

    • Hint: Execution context

    • Answer: Specifies where the pipeline or a specific stage should run (e.g., any, label, docker).

  6. What is Jenkins shared library?

    • Hint: Reuse code across pipelines

    • Answer: It allows you to store common functions or pipeline code in a central repo and use them in multiple pipelines.

  7. How do you trigger a Jenkins job remotely?

    • Hint: API token, curl

    • Answer: Use Jenkins REST API with a token, e.g., curl -X POST <jenkins-url>/job/<job-name>/build?token=<token>.

  8. What are Jenkins credentials and how do you manage them?

    • Hint: Credentials plugin

    • Answer: Stored securely in Jenkins, managed via Credentials plugin. You can access them in pipelines using credentials() or withCredentials().

  9. Explain the use of post block in Declarative Pipeline.

    • Hint: Success/Failure/Always

    • Answer: Used for post-build actions like cleanup, notifications, only runs under defined conditions.

  10. How to archive artifacts in Jenkins?

    • Hint: archiveArtifacts step

    • Answer: Use archiveArtifacts artifacts: 'target/*.jar' to retain build artifacts.

  11. What are Jenkins agents and how are they configured?

    • Hint: Nodes

    • Answer: Agents are worker nodes configured via UI or script. Can be static or auto-scaled with cloud providers.

  12. What is the use of Blue Ocean in Jenkins?

    • Hint: UI improvement

    • Answer: Blue Ocean provides a modern and user-friendly UI for Jenkins pipelines.

  13. How can you secure Jenkins?

    • Hint: Role-based access, security realm

    • Answer: Use matrix-based security, secure agents, plugins for roles, and enable security realms.

  14. How do you integrate Jenkins with GitHub?

    • Hint: Webhook + Git plugin

    • Answer: Configure GitHub webhook to trigger builds, and use Git plugin in Jenkins.

  15. What are some common Jenkins plugins you’ve used?

    • Hint: Git, Pipeline, Slack

    • Answer: Git plugin, Pipeline, Blue Ocean, Slack Notification, Credentials Binding, Maven Integration.

  16. What is a Jenkinsfile?

    • Hint: Pipeline as Code

    • Answer: It is a text file that contains the definition of a Jenkins pipeline.

  17. How do you pass parameters to a Jenkins pipeline?

    • Hint: parameters block

    • Answer: Define using parameters block and access with ${params.<param>}.

  18. How do you monitor Jenkins performance?

    • Hint: Metrics plugin

    • Answer: Use Monitoring plugin, Metrics, and external tools like Prometheus.

  19. How do you handle failing steps without breaking the pipeline?

    • Hint: catchError, try-catch

    • Answer: Use catchError or try-catch in scripted pipelines.

  20. How do you perform rollback in Jenkins pipelines?

    • Hint: Tagging, artifact version

    • Answer: Use Git tags, versioned artifacts, or redeploy from a stable version.

Section 2: Python (Build & Script Automation)

  1. How do you use Python in a Jenkins pipeline?

  2. What is a virtualenv and how is it used?

  3. How do you manage Python dependencies in a CI pipeline?

  4. Write a Python script to validate a JSON configuration file.

  5. How do you handle exceptions in a CI Python script?

  6. How do you run unit tests in Python using Jenkins?

  7. What is pytest and how is it integrated?

  8. How do you generate test coverage reports in Python?

  9. What are some best practices for writing CI-safe Python scripts?

  10. How do you lint Python code in Jenkins?

Section 3: Maven

  1. What is Maven and why is it used?

  2. What is the structure of a pom.xml file?

  3. Explain Maven lifecycle phases.

  4. How do you create a Maven project?

  5. How do you install dependencies using Maven?

  6. What is the use of Maven profiles?

  7. How do you publish Maven artifacts to Nexus/Artifactory?

  8. How do you use Maven in a Jenkinsfile?

  9. How do you skip tests in Maven builds?

  10. What are common Maven plugins used in CI/CD?

Section 4: Jenkinsfile

  1. What is the syntax of a Jenkinsfile?

  2. How do you define environment variables?

  3. How do you define a matrix build in a Jenkinsfile?

  4. How do you load shared libraries?

  5. How do you use when conditionals?

  6. How do you handle credentials securely in Jenkinsfile?

  7. How do you run shell commands in Jenkinsfile?

  8. How do you run parallel stages in a Jenkinsfile?

  9. What is input step in Jenkinsfile?

  10. How do you retry failed steps?

Section 5: Advanced CI/CD Concepts

  1. Explain CI vs CD.

  2. What are the advantages of CI/CD?

  3. How do you implement Canary deployment?

  4. What is Blue-Green deployment?

  5. How do you version your applications in CI/CD?

  6. What is Infrastructure as Code and how is it used in CI/CD?

  7. How do you manage secrets in CI/CD?

  8. What tools can you use for containerization in pipelines?

  9. How do you test Docker images in CI/CD?

  10. What is pipeline as code and its advantages?

Section 6: Troubleshooting & Optimization

  1. How do you debug a failing Jenkins pipeline?

  2. What are common issues in Jenkins builds?

  3. How do you optimize pipeline execution time?

  4. How do you ensure idempotency in pipelines?

  5. What to do when Jenkins runs out of disk space?

  6. How to prevent long-running builds from hanging Jenkins?

  7. How do you limit concurrent builds?

  8. How do you deal with flaky tests in CI?

  9. How do you schedule jobs in Jenkins?

  10. How do you clean up old jobs/artifacts?

Section 7: Miscellaneous

  1. What are ephemeral agents and their benefit?

  2. How do you implement approval gates in CI/CD?

  3. What is the role of Slack/MS Teams integration?

  4. How do you backup and restore Jenkins configuration?

  5. What is Jenkins X?

  6. Compare Jenkins with GitHub Actions.

  7. How do you handle branching strategies in CI/CD?

  8. What is multi-branch pipeline?

  9. How do you set up cross-platform builds?

  10. What is the role of Webhooks?

Section 8: Real-World Scenarios

  1. CI pipeline for microservices with Python & Docker.

  2. Handling a failing deployment in production.

  3. Designing a zero-downtime deployment pipeline.

  4. Integrating code quality checks (SonarQube).

  5. Creating a rollback strategy.

  6. Handling database migrations in CI/CD.

  7. Monitoring deployments in real-time.

  8. Setting up feature flag-driven deployment.

  9. CI/CD pipeline for multi-language repo.

  10. Automating security scans.

Section 9: Behavioral & Strategy

  1. Describe a major CI/CD challenge you faced.

  2. How do you keep up with CI/CD best practices?

  3. What is your process for onboarding new developers to CI?

  4. How do you handle downtime during pipeline maintenance?

  5. How do you train teams on CI/CD?

  6. How do you ensure pipeline quality and reliability?

  7. What metrics do you track for CI/CD performance?

  8. How do you plan CI/CD for greenfield projects?

  9. Describe a time you automated a complex manual process.

  10. How do you balance speed vs safety in deployments?

No comments :

Post a Comment