nikolaykasyanov
11/8/2013 - 1:34 PM

Script for Jenkins CI that extracts annotation of most recent annotated tag to file. This file then can be used as a release notes for Test

Script for Jenkins CI that extracts annotation of most recent annotated tag to file. This file then can be used as a release notes for TestFlight/HockeyApp deployment. Scriptler plugin is required.

/*** BEGIN META {
  "name" : "Release notes from tag message",
  "comment" : "Writes message of most recent tag with given prefix to given file",
  "parameters" : [ 'buildPath', 'tagPrefix', 'releaseNotesFilename' ],
  "core": "1.409",
  "authors" : [
    { "name" : "Nikolay Kasyanov", "email" : "corrmage@gmail.com" }
  ]
} END META**/

def performShellCommand(cmd, path) {
  def command = [ "/bin/bash", "-c", "cd '${path}' ; $cmd" ]
  def process = command.execute()
  process.waitFor()
  process.in.text
}

def tagName = performShellCommand("git for-each-ref --sort=taggerdate --format '%(tag)' refs/tags| grep --color=never \"${tagPrefix}\" | tail -1", buildPath)?.trim()

if (tagName == null) {
  System.exit(1)
}

def rawMessage = performShellCommand("git tag -l -n100 ${tagName}", buildPath)?.replace(tagName, "")?.tokenize("\n")?.collect{ it.trim() }?.join("\n")

if (rawMessage == null) {
  System.exit(1)
}

File f = new File(buildPath + "/" + releaseNotesFilename)
f.write(rawMessage)

Parameters:

  • buildPath: just pass ${WORKSPACE}
  • tagPrefix: pass specific prefix if you want to filter tags or just nothing to avoid filtering
  • releaseNotesFilename: name of the file used to export tag message. Relative to buildPath

Add "Scriptler script" build action to your configuration and then use same releaseNotesFilename value as a "Release notes filename" parameter for "Upload to HockeyApp" post-build action.

I.e. if you pass "RELEASE-NOTES.md" to releaseNotesFilename, use "RELEASE-NOTES.md" as a "Release notes filename".

DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
                   Version 2, December 2004

Copyright (C) 2004 Sam Hocevar <sam@hocevar.net>

Everyone is permitted to copy and distribute verbatim or modified
copies of this license document, and changing it is allowed as long
as the name is changed.

           DO WHAT THE FUCK YOU WANT TO PUBLIC LICENSE
  TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION

 0. You just DO WHAT THE FUCK YOU WANT TO.