2

I am an intern at a company who wants a CI environment set up as part of my intern. For emails they want to use SSL authentication and this has proven overly difficult and bothersome to do in Jenkins. So to mitigate this I have a few alternative solutions:

  • Use Gmail. This does work and is now seen as a very last resort as they really do not want the emails that Jenkins send to pass through Googles servers (even though the email contains a link to a local server that no one outside the network can access)
  • Use Jenkins without SSL. This is not desirable.
  • Write a program that an Ant task can execute as a post-build action which will then be responsible for sending the emails.

The last approach can work just fine in theory, but I have one issue. I need to get the usernames of those who last committed to the log so that they will receive the emails after Jenkins is done building (since Jenkins checks for changes in the SVN respository every minute). If I get the usernames (such as rmo or hnr) the suffix will be the same every time (like @email.com).

So how do I retrieve the committing developers of the last build using ant?

If you require additional information, let me know.

OmniOwl
  • 5,477
  • 17
  • 67
  • 116
  • It should be a small change to extract the commit author instead of the hash. – Stephen C Apr 07 '15 at 11:42
  • Not sure how it's a duplicate when the guy doesn't even use Jenkins and he uses GIT instead of SVN :/ – OmniOwl Apr 07 '15 at 11:43
  • 1
    1) The OP only just tagged that with "svn". 2) The solutions used an Ant task which would work in Jenkins just fine. – Stephen C Apr 07 '15 at 11:46
  • Here's a better duplicate. This one is specific to SVN + Ant, and it specifically gives you the committer name: http://stackoverflow.com/questions/10070871/how-to-get-the-username-of-the-last-svn-commit-using-ant. (Someone please do the honours ... I can't un-retract my vote to close.) – Stephen C Apr 07 '15 at 11:49
  • I guess you were a bit trigger happy then :P . From what I can see, the solutions you linked mentions nothing about using the `env` keyword to get anything about the svn committers. But you can use it to get the Project Name and Build number. The problem with the second solution you posted is that it requires me to specify username and password which is unnecessary as this is already used to get the source in the first place. Here is an example of what it says in the changelog: http://puu.sh/h4I8K/66ad51eaf0.png `edo` is the username that ant would need to retrieve. – OmniOwl Apr 07 '15 at 11:52
  • And that picture is taken from within Jenkins' own changelog – OmniOwl Apr 07 '15 at 11:52

1 Answers1

2

This is a valid question, don't know why it's down-voted.

Have a look at Email-ext plugin. This is the plugin for anything email-related with Jenkins.

It has options to send emails to "Developers" (last committer(s) for the current build) and "Culprits (committer since the last successful build). Unfortunately I have not seen these values exposed as environmental variables in Jenkins.

However, it has an option to save the email content to workspace. You could places the following to email content:
${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="", changesFormat="%a"}
The above should populate the email content just with commit authors from SVN, and then this would be saved to a file in workspace.

Now use whatever you want (Ant, shell, etc) to read that file for a list of email names (will need to add a suffix yourself), and send any other email content that you want.

Slav
  • 27,057
  • 11
  • 80
  • 104
  • Thanks for the answer. We are actually using that plugin, but the whole issue was that making SSL work was just more bothersome than it needed to be. We have gone with Gmail for now and then they'll have to fix that once I am gone (Internship ends in 3 days) to use their own email domain. What I wanted to do was just write a program myself that an Ant task could execute post-build to send the emails. – OmniOwl Apr 07 '15 at 17:58