How to send email notification with groovy script in Jenkins pipeline?
Pipeline Script Fundamentals
Click Here: DevOps Related Posts
Before we start with complex Jenkins interview questions for experienced people, we should know more about Jenkins. So our first question is on the simple definition of Jenkins.
SDET Interview Question and Answers
TestNG Interview questions and answers
Jenkins Interview Questions and Answers
Appium Interview Questions and Answers
Selenium Interview Questions and answers
Top 20 Complex Jenkins Interview Questions
1. What is Jenkins?
As defined in Jenkins docs, "Jenkins is a self-contained, open source automation server that can be used to automate all sorts of tasks related to building, testing, and delivering or deploying software."
We use it to create jobs or tasks which will help us to achieve CI and CD in our project.
The best thing : it is "FREE FREE FREE :)
Use Jenkins to automate your development workflow so you can focus on the work that matters most. Jenkins is commonly used for:
- Building projects
- Run tests to detect bugs and other issues as soon as they are introduced
- Static code analysis
- Deployment
Execute repetitive tasks, save time, and optimize your development process with Jenkins.
2. How to install Jenkins?
ANS: Click Here For Steps (with screenshots)
3. Can you write a pipeline script having steps called in stage?
4. What is Pipeline, Node and Stage in Jenkins?
ANS: Click Here for All Pipeline Concepts and Terminology
5. Can you write a pipeline script haveing multiple stages in it?
6. How to send email notification in Jenkins using groovy script? VERY IMP
ANS: Click Here For Answer with Groovy Script Steps
7. Can you write a pipeline script where you can call your Maven with automation suite?
node { | |
stage ('SCM checkout'){ | |
git "https://gitlab.com/mbabilo/experitest" | |
} | |
stage ('Build'){ | |
dir("comtest") { | |
sh "mvn clean install" | |
} | |
dir("comtest/target") { | |
sh "java -jar com.test-1.0-SNAPSHOT.jar" | |
} | |
} | |
} |
8. How to schedule a job in Jenkins? How to set nightly Automation Job?
ANS: Click Here For Schedule Job
9. How to create a pipeline script in Jenkins UI?
Step 1: We create a new project for the pipeline by navigating to Jenkins and then clicking on New Item.
Step 2: Next, we select Pipeline from the given list of options.
Step 3: Then, we will scroll down to Advanced Project Options and paste the pipeline script code that we saw above into the code pane and hit the Save button.
ANS: Click Here For Answer with Screenshots
Limitations of Jenkins
- Old fashioned dashboards with not many options to customize it
- Containers readiness (this has improved with Jenkins X)
- By itself, it doesn't have many features. On the other hand, there many plugins created by the community to expand its abilities
- Managing Jenkins and its pipelines as a code can be one hell of a nightmare
REVISION
18. How you can Fail a build in JenkinsFile?
Ans: By using error step from pipeline DSL we can be able to Fail a build, like : error("Build failed due to ....")
error
: Error signal
throw new Exception()
, but this step will avoid printing a stack trace.19. What is Pipeline, Node and Stage in Jenkins?
ANS: Click Here for All Pipeline Concepts and Terminology
20. How to catch error in jenkins file and set build result to failure?
Ans: By using catchError.
If the body throws an exception, mark the build as a failure, but nonetheless continue to execute the Pipeline from the statement following the catchError
step. The behavior of the step when an exception is thrown can be configured to print a message, set a build result other than failure, change the stage result, or ignore certain kinds of exceptions that are used to interrupt the build.
node { catchError { sh 'might fail' } step([$class: 'Mailer', recipients: 'admin@somewhere']) }
To explore more, please refer: catchError()
*******************************************************************For any doubts or career guidance, arrange a 1:1 call with me********************************************************************
GIT Interview Question 1 to 11
Check GIT commands for Interview preparation SET-2:
GIT Interview Question 12 to 21
Check GIT commands for Interview preparation SET-3:
GIT Interview Question 21 to 30
************************************************
✍️AUTHOR: LinkedIn Profile
************************************************
Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employee and LIVE Doubt Session
*************************************************
SeleniumWebdriver Automation Testing Interview Questions:
https://automationreinvented.blogspot.com/search/label/SeleniumWebdriver
API Testing Interview Question Set:
https://automationreinvented.blogspot.com/2022/03/top-80-api-testing-interview-questions.html
DevOps Interview Q&A:
https://automationreinvented.blogspot.com/2021/11/top-11-devops-interview-questions-and.html
Kubernetes Interview Question Set
https://automationreinvented.blogspot.com/search/label/Kubernetes
Docker Interview Question Set
https://automationreinvented.blogspot.com/Docker
Linux Interview question Set
https://automationreinvented.blogspot.com/search/label/Linux
Automation Testing/SDET Framework Design
https://automationreinvented.blogspot.com/search/label/FrameworkDesign
Java Related Interview Question Set
https://automationreinvented.blogspot.com/search/label/Java
GIT Interview Question Set:
https://automationreinvented.blogspot.com/2021/09/top-40-git-interview-questions-and.html
Coding Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Coding%20Questions
Mobile Testing Interview Question Set:
https://automationreinvented.blogspot.com/search/label/Mobile%20Testing
Python Interview Question Set for QAE - SDET - SDE:
https://automationreinvented.blogspot.com/search/label/Python
No comments:
Post a Comment