Hint: Email plugin = auto send build status emails [OK]
Common Mistakes:
Confusing with deployment tools
Thinking it monitors server health
Assuming it creates jobs
2. Which of the following is the correct syntax to enable email notifications in a Jenkins pipeline script?
easy
A. sendEmail(subject: 'Build Status', body: 'Build completed', to: 'team@example.com')
B. emailNotify(subject: 'Build Status', body: 'Build completed', to: 'team@example.com')
C. emailext(subject: 'Build Status', body: 'Build completed', to: 'team@example.com')
D. notifyEmail(subject: 'Build Status', body: 'Build completed', to: 'team@example.com')
Solution
Step 1: Recall Jenkins pipeline email syntax
The Email Extension plugin uses the emailext step to send emails.
Step 2: Match the correct function name and parameters
Only emailext(subject: 'Build Status', body: 'Build completed', to: 'team@example.com') uses emailext with correct parameters: subject, body, and to.
Final Answer:
emailext(subject: 'Build Status', body: 'Build completed', to: 'team@example.com') -> Option C
Quick Check:
Use emailext for email notifications [OK]
Hint: Use 'emailext' step for Jenkins email notifications [OK]
Common Mistakes:
Using incorrect function names
Missing required parameters
Confusing with other plugins
3. Given this Jenkins pipeline snippet:
pipeline {
agent any
stages {
stage('Build') {
steps {
echo 'Building...'
}
}
}
post {
failure {
emailext(
subject: 'Build Failed',
body: 'Please check the build logs.',
to: 'devteam@example.com'
)
}
}
}
What happens if the build fails?
medium
A. An email with subject 'Build Failed' is sent to devteam@example.com
B. No email is sent because the syntax is wrong
C. An email is sent only if the build succeeds
D. The build will retry automatically
Solution
Step 1: Analyze the post-failure block
The post { failure { ... } } block runs only if the build fails.
Step 2: Understand the emailext usage
The emailext step sends an email with the given subject and body to the specified address.
Final Answer:
An email with subject 'Build Failed' is sent to devteam@example.com -> Option A
Quick Check:
Post failure triggers email = An email with subject 'Build Failed' is sent to devteam@example.com [OK]
Hint: Post failure block sends email on build failure [OK]
Common Mistakes:
Thinking email sends on success
Assuming syntax error without checking
Confusing retry with email notification
4. You configured the Email Notification plugin but no emails are sent after build failures. Which is the most likely cause?
medium
A. SMTP server settings are missing or incorrect
B. The Jenkins job has no build steps
C. The build always succeeds
D. The plugin is not installed
Solution
Step 1: Check email sending prerequisites
Jenkins needs correct SMTP server settings to send emails.
Step 2: Identify common misconfiguration
If SMTP settings are missing or wrong, emails won't send even if plugin is configured.
Final Answer:
SMTP server settings are missing or incorrect -> Option A
Quick Check:
SMTP config missing = no emails sent [OK]
Hint: Verify SMTP settings to fix email sending issues [OK]
Common Mistakes:
Ignoring SMTP configuration
Assuming plugin auto-configures SMTP
Thinking build steps affect email sending
5. You want to send an email notification only when the build status changes (e.g., from success to failure or failure to success). Which Email Notification plugin feature should you use?
hard
A. Use the 'Send e-mail for every unstable build' option
B. Use the 'Always send e-mail' option
C. Configure a post-build script to check status manually
D. Enable 'Send e-mail only on status change' in the plugin settings
Solution
Step 1: Understand the requirement
The goal is to send emails only when build status changes, not every build.
Step 2: Identify plugin feature for status change
The Email Notification plugin has an option named 'Send e-mail only on status change' to handle this.
Step 3: Compare other options
Options A and D send emails more frequently; Configure a post-build script to check status manually requires manual scripting.
Final Answer:
Enable 'Send e-mail only on status change' in the plugin settings -> Option D
Quick Check:
Status change emails = enable plugin's status change option [OK]
Hint: Enable 'send only on status change' to reduce email noise [OK]
Common Mistakes:
Choosing options that send emails every build
Ignoring built-in plugin features
Overcomplicating with manual scripts
Recommended
Ready to prove it?
Pass the test and this pattern moves unknownstrongwhile earning +1 Grip toward your certificate.