I have a maven job configured, with the m2release plugin. It does the job perfectly, which is:

  • building my application
  • building a release version
  • publishing it to artifactory

That's great.

Now, I want that, anytime I release something, a second job is triggered, which would deploy my artifact to a server.

I can't find a way to do that.

I tried to write a Groovy script, but I can't identify in it that I am running a release run.

PS: I found out how to trigger a script in groovy here: https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin.


I finally ended up parsing the log for the version number in the output log:

// Initialize some stuff
def build = Thread.currentThread().executable
def log = manager.build.logFile.text

// We are looking for maven parameter -DreleaseVersion=1.1.1 (space at the end)
def versionFinder = log =~ /-DreleaseVersion=([0-9]+\.[0-9]+\.[0-9]+) /

if (versionFinder.size() > 0) {

  manager.listener.logger.println("Release version: " + RELEASE_VERSION);
  // Continue with release script
  // For example, here: // https://wiki.jenkins-ci.org/display/JENKINS/Groovy+plugin

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.