Jenkins Assignment– 3

Jenkins Pipelines

Basic Questions

  1. Create a Freestyle job and a Pipeline job, then note the difference between them.
  2. Create a simple Declarative Pipeline that prints “Hello Pipeline” in the console.
  3. Create a Scripted Pipeline that prints “Hello Scripted Pipeline” in the console.
  4. Write a Jenkinsfile with one stage that prints “Build Started”.
  5. Add two stages in a Declarative Pipeline: “Build” and “Test”.
  6. Create a Jenkinsfile that uses a single echo step to print a message.
  7. Create a pipeline with three stages: Build, Test, and Deploy.
  8. Add a post section in a Declarative Pipeline to print a message after success.
  9. Add a post section in a Declarative Pipeline to print a message after failure.
  10. Write a Jenkinsfile that defines an environment variable and prints it.
  11. Create a pipeline that uses an environment variable inside an echo step.
  12. Create a Declarative Pipeline that runs a shell command to list files.
  13. Write a Jenkinsfile with multiple steps inside a single stage.
  14. Create a pipeline with a stage named “Compilation” that runs a dummy command.
  15. Create a pipeline that has one stage for printing system environment variables.
  16. Write a Jenkinsfile that uses when condition to run a stage only if branch is “main”.
  17. Write a pipeline that prints the current build number using environment variables.
  18. Write a Jenkinsfile that uses agent any to run the job on any node.
  19. Write a pipeline that runs only one step: printing the Jenkins workspace path.
  20. Store a Jenkinsfile in a GitHub repository and run it from Jenkins.

Intermediate Questions

  1. Create a pipeline with three stages (Build, Test, Deploy) and add two steps in each stage.
  2. Create a pipeline with parallel stages for “Unit Tests” and “Integration Tests”.
  3. Write a Scripted Pipeline that runs three steps inside a single node block.
  4. Write a Declarative Pipeline that uses tools block to define Maven and prints its version.
  5. Create a Jenkinsfile that uses parameters to take branch name as input.
  6. Create a Jenkinsfile that uses parameters to take username as input and print it.
  7. Write a pipeline that includes both success and failure post actions.
  8. Create a Jenkinsfile with an always post action that cleans the workspace.
  9. Create a Jenkinsfile that runs a stage only if the build was triggered manually.
  10. Create a pipeline that uses a custom environment variable inside multiple stages.
  11. Write a Declarative Pipeline that includes a timeout block for 2 minutes.
  12. Write a pipeline that retries a failing command three times.
  13. Store a Jenkinsfile in GitHub and configure Jenkins Pipeline to load it automatically.
  14. Create a multi-branch pipeline project that uses Jenkinsfile from each branch.
  15. Create a Jenkinsfile with four stages: Checkout, Build, Test, and Deploy.
  16. Create a Jenkinsfile that uses post actions to archive build artifacts.
  17. Write a pipeline that runs a shell script from the workspace.
  18. Write a Jenkinsfile that uses credentials to print a masked password.
  19. Create a pipeline that uses input step to ask for manual approval before deploy.
  20. Create a Jenkinsfile with parallel stages that run different shell commands.

Advanced Questions

  1. Write a Scripted Pipeline that dynamically creates stages based on a list of modules.
  2. Write a Declarative Pipeline that builds different branches using when conditions.
  3. Create a Jenkinsfile with multiple post actions (success, failure, unstable, always).
  4. Write a pipeline that sends an email notification in the post section.
  5. Write a Jenkinsfile that loads shared library functions and uses them in stages.
  6. Create a pipeline that builds and tests a project inside a Docker container.
  7. Write a Jenkinsfile that uses parallel block with four stages running together.
  8. Write a Declarative Pipeline that triggers another job after success.
  9. Write a Jenkinsfile that publishes JUnit test results in the pipeline.
  10. Create a Jenkinsfile that packages code and pushes it to an artifact repository.