Jenkins Assignment– 3
Jenkins Pipelines
Basic Questions
- Create a Freestyle job and a Pipeline job, then note the difference between them.
- Create a simple Declarative Pipeline that prints “Hello Pipeline” in the console.
- Create a Scripted Pipeline that prints “Hello Scripted Pipeline” in the console.
- Write a Jenkinsfile with one stage that prints “Build Started”.
- Add two stages in a Declarative Pipeline: “Build” and “Test”.
- Create a Jenkinsfile that uses a single echo step to print a message.
- Create a pipeline with three stages: Build, Test, and Deploy.
- Add a post section in a Declarative Pipeline to print a message after success.
- Add a post section in a Declarative Pipeline to print a message after failure.
- Write a Jenkinsfile that defines an environment variable and prints it.
- Create a pipeline that uses an environment variable inside an echo step.
- Create a Declarative Pipeline that runs a shell command to list files.
- Write a Jenkinsfile with multiple steps inside a single stage.
- Create a pipeline with a stage named “Compilation” that runs a dummy command.
- Create a pipeline that has one stage for printing system environment variables.
- Write a Jenkinsfile that uses when condition to run a stage only if branch is “main”.
- Write a pipeline that prints the current build number using environment variables.
- Write a Jenkinsfile that uses agent any to run the job on any node.
- Write a pipeline that runs only one step: printing the Jenkins workspace path.
- Store a Jenkinsfile in a GitHub repository and run it from Jenkins.
Intermediate Questions
- Create a pipeline with three stages (Build, Test, Deploy) and add two steps in each stage.
- Create a pipeline with parallel stages for “Unit Tests” and “Integration Tests”.
- Write a Scripted Pipeline that runs three steps inside a single node block.
- Write a Declarative Pipeline that uses tools block to define Maven and prints its version.
- Create a Jenkinsfile that uses parameters to take branch name as input.
- Create a Jenkinsfile that uses parameters to take username as input and print it.
- Write a pipeline that includes both success and failure post actions.
- Create a Jenkinsfile with an always post action that cleans the workspace.
- Create a Jenkinsfile that runs a stage only if the build was triggered manually.
- Create a pipeline that uses a custom environment variable inside multiple stages.
- Write a Declarative Pipeline that includes a timeout block for 2 minutes.
- Write a pipeline that retries a failing command three times.
- Store a Jenkinsfile in GitHub and configure Jenkins Pipeline to load it automatically.
- Create a multi-branch pipeline project that uses Jenkinsfile from each branch.
- Create a Jenkinsfile with four stages: Checkout, Build, Test, and Deploy.
- Create a Jenkinsfile that uses post actions to archive build artifacts.
- Write a pipeline that runs a shell script from the workspace.
- Write a Jenkinsfile that uses credentials to print a masked password.
- Create a pipeline that uses input step to ask for manual approval before deploy.
- Create a Jenkinsfile with parallel stages that run different shell commands.
Advanced Questions
- Write a Scripted Pipeline that dynamically creates stages based on a list of modules.
- Write a Declarative Pipeline that builds different branches using when conditions.
- Create a Jenkinsfile with multiple post actions (success, failure, unstable, always).
- Write a pipeline that sends an email notification in the post section.
- Write a Jenkinsfile that loads shared library functions and uses them in stages.
- Create a pipeline that builds and tests a project inside a Docker container.
- Write a Jenkinsfile that uses parallel block with four stages running together.
- Write a Declarative Pipeline that triggers another job after success.
- Write a Jenkinsfile that publishes JUnit test results in the pipeline.
- Create a Jenkinsfile that packages code and pushes it to an artifact repository.