Release notes from XX previous build change logs in Markdown

31 views
Skip to first unread message

Brantone

unread,
Aug 22, 2014, 8:46:48 PM8/22/14
to jenkins...@googlegroups.com
Looking to publish release notes based on change logs from SCM commit messages .. and preferably in Markdown, but plain text will do ... alas, surprised no plugin exists (that I can find), so curious how others handle such a scenario, or else I guess I'm writing a plugin :)
I do have https://wiki.jenkins-ci.org/display/JENKINS/Changes+Since+Last+Success+Plugin ; however, formatting for that is machine (html, xml, json), but nothing just plain text.
Quick scan of mailing list didn't reveal anything "ah ha!", so wondering if this is such a unique situation, or already solved and it's obvious I'm just not seeing it.

Cheers.

Daniel Beck

unread,
Aug 22, 2014, 9:03:24 PM8/22/14
to jenkins...@googlegroups.com
Looks like JENKINS-12032, which I haven't yet begun work on. Feel free to take over.
> --
> You received this message because you are subscribed to the Google Groups "Jenkins Users" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to jenkinsci-use...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Brenton Bartel

unread,
Aug 24, 2014, 2:39:25 AM8/24/14
to jenkins...@googlegroups.com
I thought HockeyApp already had the radio button to do that (or is it broken?) ... This would still only put it in the current build, not necessarily for span over build numbers, correct?
I'm thinking more simply xml -> MD converter/executor.



You received this message because you are subscribed to a topic in the Google Groups "Jenkins Users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/jenkinsci-users/U4SReCE2tok/unsubscribe.
To unsubscribe from this group and all its topics, send an email to jenkinsci-use...@googlegroups.com.

Brantone

unread,
Jul 14, 2015, 8:54:01 PM7/14/15
to jenkins...@googlegroups.com
I created this Groovy script, which relies on PARENT_JOB_NAME and PARENT_JOB_NUMBER as params, but could be be better expanded to look at it's parent directly rather than relying on those.
Progresses up the tree of triggered jobs, collecting change notes, then pumps it all into a new param RELEASE_NOTES  which can then be used by HockeyApp...


import hudson.model.*

// Function makes it easier with recursion
def getBuildChangeLog(thisBuild) {
 
def thisLog = []

 
if (!thisBuild.changeSet.isEmptySet()) {
    thisLog
.addAll(thisBuild.changeSet.getItems())
 
}

 
for (cause in thisBuild.causes) {
   
if (cause.class.toString().contains("UpstreamCause")) {
     
def upProject = hudson.model.Hudson.instance.getItemByFullName(cause.upstreamProject)
     
def upBuild = upProject.getBuildByNumber(cause.upstreamBuild)
      thisLog
.addAll(getBuildChangeLog(upBuild))
   
}
 
}

 
return thisLog
}

// =============================================

// Relies on some vars to be passed to find parent.
def buildVars = build.buildVariableResolver

// If "RELEASE_NOTES" has data, just keep it.
if (buildVars.resolve("RELEASE_NOTES")?.trim()) {
 
return;
}

def parentJob = hudson.model.Hudson.instance.getItemByFullName(buildVars.resolve("PARENT_JOB_NAME"))
def parentBuild = parentJob.getBuildByNumber(buildVars.resolve("PARENT_JOB_NUMBER").toInteger())
def parentEnv = parentBuild.getEnvironment()

def changeLog = getBuildChangeLog(build)
def releaseNotes = "##Release Notes\n"

if (parentEnv.containsKey("GIT_COMMIT")) {
   
def gitCommit = parentEnv["GIT_COMMIT"]
   
def shortGitCommit = gitCommit[0..6]
    releaseNotes
+= "Git Hash: " + shortGitCommit + "\n"
}
else if (parentEnv.containsKey("P4_CHANGELIST")) {
    releaseNotes
+= "Perforce changelist: " + parentEnv["P4_CHANGELIST"] + "\n"
}

if (changeLog.empty) {
  releaseNotes
+= "###No changes since previous build"
}
else {
  releaseNotes
+= "###Change Log:\n"
  changeLog
.each {
    releaseNotes
+= "* ${it.msg}\n"
 
}
}

println releaseNotes

newParam
= new StringParameterValue('RELEASE_NOTES', releaseNotes)

// Note: this assumes that params are already in use
def curParams = build.getAction(ParametersAction.class)
build
.replaceAction(curParams.merge(new ParametersAction(newParam)))

Reply all
Reply to author
Forward
0 new messages