Friday 22 July 2022

Top 20 Jenkins Interview Questions and Answers Set -02?



 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.


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 :)

What to Use Jenkins for and When to Use It

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?

    agent any
        stages {
            stage ('Build') {
                steps {
                    echo
                    'Running build phase. '
                }
            }
        }
    }

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?

agent any
    stages {
        stage ('Build') {
        }
        stage ('Test') {
        
        }
        stage ('Deploy') {
        
        }
     

    }   

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.



Step 4: We need to set up a test build, which can be quickly done by the Jenkins UI by clicking Build Now.



Step 5: We can see a new build generating under the build history as we click on Build Now. The console logs output can be viewed by clicking on the Build.

10. How to create parameterized job in Jenkins? VERY IMP

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

Signals an error. Useful if you want to conditionally abort some part of your program. You can also just 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 


********************************************************************


  • Interview questions for SDET/Automation Testing:
  • Top 21 GIT interview questions
  • Top 30 Selenium Webdriver Interview Q&A 
  • Top 20 API Testing Interview Q&ASelenium Interview Question SET-4 
  • Selenium Interview Question SET-1
  • Selenium Interview Question SET-2
  • Selenium Interview Questions SET-3
  • Selenium Interview Question SET-4

      
  •        Check GIT commands for Interview preparation SET-1:

    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

    ************************************************

    ✍️AUTHORLinkedIn Profile

    ************************************************

    Learn (API-Microservice)Testing+ Selenium UI Automation-SDET with Self Paced Videos prepared by FAANG employee and LIVE Doubt Session 

    SDET TRANING VIDEOS AVAILABLE with Live Doubt Session(course-1 below,API TRaining Videos With Class Notes and Coding Set) and (API+UI, both course-1 & 2 below) Check Training Page for Course Content or reach out @whatsapp +91-9619094122. 
    This includes classnotes, 300+ interview questions, 3 projects, Java Coding question set for product companies along with career guidance from FAANG employees for Automation and SDET.

    For more details whatsapp : https://lnkd.in/dnBWDM33



    *************************************************

    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

    All Time Popular Posts

    Most Featured Post

    API Status Codes with examples for QA-Testers

      🔺 LinkedIn: https://www.linkedin.com/in/sidharth-shukla-77b53145/ 🔺 Telegram Group:  https://t.me/+FTf_NPb--GQ2ODhl 🏮In API testing, it...