Ismail Sen
Ismail Sen

Reputation: 581

Add SVN_AUTHOR and SVN_COMMIT_MESSAGE as env var in JENKINS

In my JENKINS job configuration I'm sending an email to developers when a build is done.

In this mail I send : $PROJECT_NAME $BUILD_NUMBER $BUILD_STATUS $BUILD_URL and $SVN_REVISION.

I use Email Extension Plugin v 2.38.1.

In my email body, I want to add : SVN_AUTHOR and SVN_COMMIT_MESSAGE.

In JENKINS such env var doesn't exist. So is it possible to create them ? What plugin to use ?

Ismail

Upvotes: 1

Views: 1990

Answers (1)

Slav
Slav

Reputation: 27495

Click the question mark next to Content Token Reference, it will show you a lot of things you can use.

Try this:

${CHANGES_SINCE_LAST_SUCCESS, reverse=true, format="<b>Changes for Build #%n</b><br>%c<br>", changesFormat="<br>[%a] - (%r) %p<br> %m<br>"}

This will produce output like:

Changes for Build #123
[svn-author-name] - (svn-rev) path-to-changed-file
svn commit message here

Here is the relevant part from documentation:

format - for each commit listed, a string containing %X, where %X is one of %a for author, %d for date, %m for message, %p for paths, or %r for revision. Not all revision systems support %d and %r. If specified, showPaths is ignored. Defaults to "[%a] %m\n".

The above is relevant to Email-ext plugin and will suffice for what you described in your question.

However, if you really want to make these available as environment variables available to other build steps and/or scripts, you would need to:

  • Manually extract them from your SCM (probably using svn log command and some grepping/sedding/awking)
  • Save the output to file, in format param=value
  • Use EnvInject plugin build step to load the file as environment variables for other build steps/scripts

Upvotes: 3

Related Questions