Jenkins Jenkins CI/CD Integration 2 — Questions and Answers
Question 1: What is the purpose of the `archiveArtifacts` step in a Jenkins Pipeline?
- Backs up the Jenkins configuration
- Saves specified files from the workspace to Jenkins so they can be downloaded after the build (Correct answer)
- Pushes artifacts to a Maven repository
- Compresses log files for storage
Correct answer: Saves specified files from the workspace to Jenkins so they can be downloaded after the build
The `archiveArtifacts` step saves files from the build workspace to Jenkins, making them downloadable from the build results page.
Question 2: Which Jenkins feature allows you to deploy to different environments (dev, staging, prod) using the same pipeline?
- Multi-environment plugin
- Parameterized builds with environment parameters (Correct answer)
- Environment Deployer Plugin
- Stage Gate Manager
Correct answer: Parameterized builds with environment parameters
Parameterized builds let you pass an environment parameter (dev/staging/prod) to the same pipeline, which then deploys to the specified target.
Question 3: What is a Jenkins Multibranch Pipeline?
- A pipeline that runs on multiple agents in parallel
- A pipeline project that automatically discovers branches and pull requests in a repository and creates pipelines for each (Correct answer)
- A pipeline with multiple Jenkinsfiles
- A pipeline that manages multiple Jenkins controllers
Correct answer: A pipeline project that automatically discovers branches and pull requests in a repository and creates pipelines for each
A Multibranch Pipeline project scans a repository for branches and pull requests, automatically creating and managing a pipeline for each one using its Jenkinsfile.
Question 4: What does the `publishTestResults` (or `junit`) step do in a Jenkins Pipeline?
- Runs unit tests inside the pipeline
- Parses JUnit XML test result files and publishes them to the build page for reporting and trending (Correct answer)
- Publishes test results to a third-party service
- Generates a code coverage report
Correct answer: Parses JUnit XML test result files and publishes them to the build page for reporting and trending
The `junit` pipeline step reads JUnit-format XML result files and displays pass/fail statistics and trends on the Jenkins build page.
Question 5: How does Jenkins integrate with Docker to produce a containerized application artifact?
- Jenkins SSH into Docker Hub to pull base images
- Jenkins uses the Docker Pipeline plugin to build Docker images from a Dockerfile within the pipeline and push to a registry (Correct answer)
- Jenkins auto-wraps all build outputs in Docker containers
- Jenkins requires the Docker daemon on the controller
Correct answer: Jenkins uses the Docker Pipeline plugin to build Docker images from a Dockerfile within the pipeline and push to a registry
The Docker Pipeline plugin allows pipelines to build Docker images using `docker.build()` and push them to a registry using `docker.push()` within the pipeline steps.
Question 6: What is a Jenkins Organization Folder?
- A folder plugin for organizing jobs visually
- A project type that scans an entire GitHub/Bitbucket organization and creates Multibranch Pipelines for all qualifying repositories (Correct answer)
- A container for managing Jenkins user groups
- A Jenkins backup folder for configuration files
Correct answer: A project type that scans an entire GitHub/Bitbucket organization and creates Multibranch Pipelines for all qualifying repositories
An Organization Folder scans all repositories in a GitHub org or Bitbucket project and automatically creates a Multibranch Pipeline for each repo that contains a Jenkinsfile.
What is the purpose of the `archiveArtifacts` step in a Jenkins Pipeline?