Git Changelog Plugin

Build Status

Creates a changelog, or release notes, based on Git commits between 2 revisions.

This can also be done with a command line tool.

Usage

You can use this plugin either in a pipeline or as a post-build action.

There is a complete running example available here: https://github.com/tomasbjerre/jenkins-configuration-as-code-sandbox

Pipeline

The plugin is compatible with the pipeline plugin and can be configured to support many use cases. You probably want to adjust it using the Snippet Generator.

The gitChangelog step can return:

The template and context is documented here.

It can integrate with issue management systems to get titles of issues and links. You will probably want to avoid specifying credentials in plain text in your script. One way of doing that is using the credentials binding plugin. The supported integrations are:

You can create a file or maybe publish the changelog with:

You can filter out a subset of the commits by:

You can make the changelog prettier by:

Check the Snippet Generator to see all features!

Pipeline with context

Here is an example that clones a repo, gathers all jiras and adds a link to jira in the description of the job. The context contains much more then this and is documented here.

node {
 deleteDir()
 sh """
 git clone [email protected]:jenkinsci/git-changelog-plugin.git .
 """

 def changelogContext = gitChangelog returnType: 'CONTEXT',
  from: [type: 'REF', value: 'git-changelog-1.50'],
  to: [type: 'REF', value: 'master'],
  jira: [issuePattern: 'JENKINS-([0-9]+)\\b', password: '', server: '', username: '']

 Set<String> issueIdentifiers = new TreeSet<>()
 changelogContext.issues.each { issue ->
  if (issue.name == 'Jira') {
   issueIdentifiers.add(issue.issue)
  }
 }
 currentBuild.description = "http://jira.com/issues/?jql=key%20in%20%28${issueIdentifiers.join(',')}%29"
}

Pipeline with string

Here is an example that clones a repo and publishes the changelog on job page. The template and context is documented here.

node {
 deleteDir()
 sh """
 git clone [email protected]:jenkinsci/git-changelog-plugin.git .
 """

 def changelogString = gitChangelog returnType: 'STRING',
  from: [type: 'REF', value: 'git-changelog-1.50'],
  to: [type: 'REF', value: 'master'],
  template: """
  <h1> Git Changelog changelog </h1>

<p>
Changelog of Git Changelog.
</p>

{{#tags}}
<h2> {{name}} </h2>
 {{#issues}}
  {{#hasIssue}}
   {{#hasLink}}
<h2> {{name}} <a href="{{link}}">{{issue}}</a> {{title}} </h2>
   {{/hasLink}}
   {{^hasLink}}
<h2> {{name}} {{issue}} {{title}} </h2>
   {{/hasLink}}
  {{/hasIssue}}
  {{^hasIssue}}
<h2> {{name}} </h2>
  {{/hasIssue}}

   {{#commits}}
<a href="https://github.com/tomasbjerre/git-changelog-lib/commit/{{hash}}">{{hash}}</a> {{authorName}} <i>{{commitTime}}</i>
<p>
<h3>{{{messageTitle}}}</h3>

{{#messageBodyItems}}
 <li> {{.}}</li> 
{{/messageBodyItems}}
</p>

  {{/commits}}

 {{/issues}}
{{/tags}}
  """

 currentBuild.description = changelogString
}

Post-build action

When the plugin is installed, it will add a new post build action in Jenkins job configuration.

Git Changelog

A couple of revisions are configured along with some other optional features. A editable template is available for the user to tweak.

Select references

The changelog is created from parsing Git and rendering the template with a context derived from the configured revisions.

Tweak template

Development

This plugin can be built and started with maven and Jenkins' hpi plugin:

./run.sh

The functionality is implemented in git-changelog-lib. Pull requests are welcome!