Skip to content
CodeKruPro

Read the Jenkinsfile: when is the e-mail sent?

QuizEasyAsked in: Accenture, Capgemini, Infosys, TCS, Wipro

Read the Jenkinsfile.

Jenkinsfile

pipeline {
    agent { label 'linux' }
    parameters {
        choice(name: 'BROWSER', choices: ['chrome', 'firefox'], description: 'Browser for the UI tests')
    }
    triggers {
        cron('H 2 * * 1-5')
    }
    options {
        timeout(time: 60, unit: 'MINUTES')
    }
    stages {
        stage('Checkout') {
            steps {
                checkout scm
            }
        }
        stage('Test') {
            steps {
                sh "mvn -B test -Dbrowser=${params.BROWSER}"
            }
        }
    }
    post {
        always {
            junit 'target/surefire-reports/*.xml'
        }
        failure {
            mail to: 'qa-team@example.com',
                 subject: "Tests failed: ${env.JOB_NAME} #${env.BUILD_NUMBER}",
                 body: "See ${env.BUILD_URL}"
        }
    }
}

When is the e-mail sent?

  • Only when the build result is FAILURE
  • After every build
  • Only when the build succeeds
  • When the junit step finds failed tests and the build becomes UNSTABLE

This question is part of Pro+

Pro+ opens every question in Interview Prep and the mock interview. Every article and the first 2 questions of each topic stay free. Hands-on Selenium and API tasks follow their course lesson's own lock.

See Pro+

Already have Pro+? Sign in