0
0
Jenkinsdevops~10 mins

Why notifications matter in Jenkins - Test Your Understanding

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 after a Jenkins build.

Jenkins
post {
  always {
    emailext [1] {
      to: 'team@example.com'
      subject: 'Build Notification'
      body: 'The build has completed.'
    }
  }
}
Drag options to blanks, or click blank then click option'
Amail
Bnotify
Cemail
Dsend
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'notify' instead of 'send' causes a syntax error.
Using 'mail' is a different step and not part of emailext.
2fill in blank
medium

Complete the code to notify only when the build fails.

Jenkins
post {
  [1] {
    emailext send {
      to: 'team@example.com'
      subject: 'Build Failed'
      body: 'Please check the build logs.'
    }
  }
}
Drag options to blanks, or click blank then click option'
Asuccess
Balways
Cfailure
Dunstable
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'always' sends notifications every time.
Using 'success' sends notifications only on success.
3fill in blank
hard

Fix the error in the notification block to correctly send an email on unstable builds.

Jenkins
post {
  unstable {
    emailext [1] {
      to: 'team@example.com'
      subject: 'Build Unstable'
      body: 'The build is unstable.'
    }
  }
}
Drag options to blanks, or click blank then click option'
Asend
Bnotify
Cemail
Dmail
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'notify' or 'email' causes the pipeline to fail.
Using 'mail' is a different plugin step.
4fill in blank
hard

Fill both blanks to send notifications only when the build is successful and unstable.

Jenkins
post {
  [1] {
    emailext send {
      to: 'team@example.com'
      subject: 'Build Success'
      body: 'The build succeeded.'
    }
  }
  [2] {
    emailext send {
      to: 'team@example.com'
      subject: 'Build Unstable'
      body: 'The build is unstable.'
    }
  }
}
Drag options to blanks, or click blank then click option'
Asuccess
Bfailure
Cunstable
Dalways
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'failure' instead of 'success' sends notifications on failure.
Using 'always' sends notifications every time.
5fill in blank
hard

Fill all three blanks to send notifications with dynamic subject and body based on build status.

Jenkins
post {
  [1] {
    emailext send {
      to: 'team@example.com'
      subject: 'Build [2]'
      body: 'The build status is [3].'
    }
  }
}
Drag options to blanks, or click blank then click option'
Afailure
Bsuccess
CFAILED
DSUCCESS
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing failure block with success messages.
Using lowercase status words in subject and body.