Jenkins Interview Questions For Freshers
1. What is Jenkins?
Jenkins is an open source continuous integration/continuous delivery and deployment (CI/CD) automation software DevOps tool written in the Java programming language. It is used to implement CI/CD workflows, called pipelines.
2. Tell me something about Continuous Integration, Continuous Delivery, and Continuous Deployment?
Continuous Delivery: This is a Software Development Process where the continuously integrated (CI) changes will be tested & deployed continuously into a specific environment, generally through a manual release process, after all the quality checks are successful
Read Also – What is Linux operating system?
Continuous Deployment: A Software Development practice where the continuously integrated (CI) changes are deployed automatically into the target environment after all the quality checks are successful
3. How do you store credentials in Jenkins securely?
To maximize security, credentials configured in Jenkins are stored in encrypted form on the controlling Jenkins instance (encrypted by the Jenkins instance ID) and are controlled only through their credential ID in pipeline projects.
4. How can we stop a scheduled job from being executed temporarily?
Disable the task from the task details page to temporarily stop all scheduled execution and other factors/events that trigger the task and enable it back to restart the task schedule/trigger.
5. What are the credential types supported by Jenkins?
- Secret text – A token such as an API token, JSON token, etc.
- Username and password – Basic Authentication can be stored as a credential as well.
- Secret file – A secret file used to authenticate some secure data services & security handshakes.
- SSH Username with a private key – An SSH public/private key pair for Machine to Machine authentication.
- Certificate – a PKCS#12 certificate file and an optional password.
- Docker Host Certificate Authentication credentials.
And as we can guess, this can be extended to several other extensible credential types like – AWS credential, Azure secrets, etc. using commonly available plugins.
6. How to get the Jenkins version programmatically in Jobs/Pipelines or nodes other than master?
This contains the version number of Jenkins, like “1.404”. This is also a good way to check if an URL is a Jenkins URL.
7. What is Artifact Archival & how to do it in Pipelines?
Answer: Artifact are the exportable/storable/archivable results of a specific job build. This can be configured using a plugin called – Copy artifact Plugin. Based on the configured pattern, the files/directories matching the configured patterns will be archived for a Jenkins build, which can be used for future references. In the pipeline, it can be configured as follows –
archiveArtifacts artifacts: ‘output/**/*’
8. How to configure inclusions & exclusions in Artifacts Archival?
For e.g.
archiveArtifacts artifacts: ‘output/*.txt’, excludes: ‘output/specific_file.txt’
The above command will archive all the text files from the output folder except specific_file.txt
9. How can we share information between different build steps or stages in a Jenkins Job?
Each manufacturing stage or phase will be running in its own process and hence sharing information between two different manufacturing stages is not so direct. We can use files, database entries, environment variables, etc. to share information from one build stage to another or in a post-build action.
10. How to create & use a Shared Library in Jenkins?
- A Repository with pipeline shared library code in SCM.
- An appropriate SCM Plugin configuration for the Jenkins instance.
- Global Shared Library should be configured in Jenkins Global configuration.
- Include the Shared Library in the Pipeline Code and use the methods defined in the Jenkins Shared Library.
E.g.
#!/urs/bin/env groovy
11. What is In-process Script Approval and how it works?
This protection is provided by the Script Security plugin. As soon as an unsafe method is used in any of the scripts, the “In-process Script Approval” action should appear in “Manage Jenkins” to allow Administrators to make a decision about which unsafe methods, if any, should be allowed in the Jenkins environment.
This in-process script approval inherently improves the security of the overall Jenkins ecosystem.
12. Can we monitor Jenkins using common Observability tools?
Common monitoring platforms like Datadog, Prometheus, JavaMelody and a few others have their respective Jenkins plugins which, when configured, sends metrics to the respective monitoring platform, which can then be visualized with the latest tools and technologies. It can be configured with alarms and notifications to get immediate attention if something goes wrong.
13.Which command is used to start Jenkins?
- Open Command Prompt
- From the Command Prompt browse the directory where Jenkins. war resides
- Run the command given below:
D:\>Java –jar Jenkins.war
14. What are Declarative Pipelines in Jenkins?
No semicolon to be used as a statement separator. The top-level pipeline should be enclosed within block viz;
The common syntax is:
pipeline { /* Declarative Pipeline */ }
Blocks must contain Sections, Directives, steps or assignments.
pipeline { agent any stages { stage(‘Build’) { steps { // Statements… } } stage (‘Test’) { steps { // Statements… } } } }
The above code has 3 major elements
- Pipeline: The block of script contents.
- Agent: Defines where the pipeline will start running from.
- Stage: The pipelines contain several steps enclosed in the block called Stage.
15. What is Groovy in Jenkins?
Apache Groovy is a dynamic object-oriented programming language used as a scripting language for the Java platform. Groovy is used to orchestrate Jenkins pipelines and enables different teams to contribute work in different languages
16. What is Jenkinsfile?
Answer: The text file where all the definitions of pipelines are defined is called Jenkinsfile. It is being checked in the source control repository.
17. Which CI Tools are used in Jenkin?
- Jenkins
- GitLab CI
- Travis CI
- CircleCI
- Codeship
- Go CD
- TeamCity
- Bamboo
Tag –
Jenkins Interview Questions For Freshers, Jenkins Interview Questions For Freshers, Jenkins Interview Questions For Freshers, Jenkins Interview Questions For Freshers.
- Dependency Track – End To End CI/CD Pipeline - November 29, 2024
- Dependency-track Jenkins Integration - November 27, 2024
- Jenkins Setup for PyTest + Selenium Automation Testing - November 27, 2024