0
0
Jenkinsdevops~10 mins

Email notifications in pipelines in Jenkins - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to send an email notification in a Jenkins pipeline.

Jenkins
emailext to: '[1]', subject: 'Build Notification', body: 'The build is complete.'
Drag options to blanks, or click blank then click option'
Adevteam@example.com
Badmin@domain.com
Csupport@helpdesk.com
Dbuild@company.com
Attempts:
3 left
💡 Hint
Common Mistakes
Leaving the to field empty or with an invalid email.
Using a variable name instead of an email string.
2fill in blank
medium

Complete the code to trigger email notification only when the build fails.

Jenkins
post {
  failure {
    emailext to: 'build@company.com', subject: 'Build Failed', body: '[1]'
  }
}
Drag options to blanks, or click blank then click option'
AThe build succeeded.
BThe build has failed. Please check the logs.
CBuild is running.
DBuild was aborted.
Attempts:
3 left
💡 Hint
Common Mistakes
Using a success message in failure block.
Leaving the body message empty.
3fill in blank
hard

Fix the error in the email notification syntax to send to multiple recipients.

Jenkins
emailext to: '[1]', subject: 'Build Status', body: 'Check the build details.'
Drag options to blanks, or click blank then click option'
Adev1@example.com, dev2@example.com
Bdev1@example.com; dev2@example.com
Cdev1@example.com dev2@example.com
Ddev1@example.com|dev2@example.com
Attempts:
3 left
💡 Hint
Common Mistakes
Using semicolons or spaces instead of commas.
Using invalid separators like pipes.
4fill in blank
hard

Fill both blanks to send an email only when the build is unstable and include the build URL in the body.

Jenkins
post {
  [1] {
    emailext to: 'build@company.com', subject: 'Build Unstable', body: '[2]'
  }
}
Drag options to blanks, or click blank then click option'
Aunstable
Bsuccess
CcurrentBuild.fullDisplayName
Denv.BUILD_URL
Attempts:
3 left
💡 Hint
Common Mistakes
Using success instead of unstable.
Not including the build URL correctly.
5fill in blank
hard

Fill all three blanks to create a map of email parameters with recipient, subject, and body including the build status.

Jenkins
def emailParams = [to: '[1]', subject: '[2]', body: "[3]"]
emailext emailParams
Drag options to blanks, or click blank then click option'
Aqa@company.com
BBuild Notification
CThe build status is ${currentBuild.currentResult}
DThe build failed
Attempts:
3 left
💡 Hint
Common Mistakes
Hardcoding the build status instead of using a variable.
Using an incorrect email format.