5

I want to write a script in pre-send script (from Editable-Email Notification plugin) to send the email (set the cancel flag to true) ONLY when the branch failed is a master branch (as in have master in the name of the branch). How do I do this?

1 Answers1

2

How to trigger an email based on a specific condition for a successful build in Jenkins

your git plugin holds a env varible or you can make a env variable with branch name. then use the above solution to drop mail.

GIT Plugin provides you the env variable

GIT_BRANCH - Name of the remote repository (defaults to origin), followed by name of the branch currently being used, e.g. "origin/master" or "origin/foo"

Community
  • 1
  • 1
DevD
  • 565
  • 4
  • 15
  • thanks for the reply, how do i create an env variable with branch name? and where do i create it? – theChosenOne Mar 20 '15 at 14:38
  • http://stackoverflow.com/questions/6245570/how-to-get-current-branch-name-in-git you can get the local branch name using this. i have t check on git plugin – DevD Mar 21 '15 at 08:45
  • hey.. there is an env variable called "GIT_BRANCH" in https://wiki.jenkins-ci.org/display/JENKINS/Git+Plugin. you can use that directly – DevD Mar 21 '15 at 08:49