×
Find plugins

Git Changelog1.57Minimum Jenkins requirement: 2.1ID: git-changelog

View Git Changelog on the plugin site for more information.

Extracts a changelog out of commit messages between two GIT revisions, the latest release tags are searched automatically. This changelog can be postprocessed and converted to either an human readable git changelog listing all commits, or a JIRA filter URL.

Usage

You can use this plugin either:

  • As a post-build action
    Where the changelog, or releasenotes, are created from commits between 2 commits. Those can be first commit in repo to master, or any other branches or specific commits. You may want to use variables provided by the Git Plugin to create a changelog from GIT_PREVIOUS_SUCCESSFUL_COMMIT to GIT_COMMIT or perhaps just GIT_PREVIOUS_COMMIT to GIT_COMMIT. Or, if you are using Atlassian Bitbucket Server, you may want to provide them with Pull Request Notifier for Bitbucket Server as described in this blog post.
    • To crate a summary on Jenkins job containing changelog or releasenotes.
    • To create a file in workspace containing changelog or releasenotes.
    • To create a MediaWiki page containing changelog or releasenotes.
    • To produce a file containing the jira filter and some informative lines.
  • To provide replacement text for the Token Macro Plugin, to send
    emails, for example.

The templates that are used here are documented here.

Using a Post-build Action

Once this plugin is installed, there will be some new items in the post build actions list.

Summary on Jenkins job page

It may be configured something like this.

And the results may be something like this.

File in Jenkins workspace

It may be configured something like this.

And the file may be created like this.

Page on MediaWiki

It may be configured something like this.

And the created wiki page may look like this.

There will also be a link to the wiki page from the job in the job list.

JIRA Filter

The following documentation explains to set up the JIRA Filter post-build action. Using the basic changelog post-build action
is even easier, as it does not need any further configuration.

On any jenkins project using Git as Source Code Management, add "Publish JIRA Filter" Post-build Action. A form with a few
input fields appears where you can configure the behaviour. Just below the input fields their meaning and default behaviour is
explained.

If you leave the file input empty, the information will be logged into the jenkins console.

If you specify a filename, you can use other plugins like HTML Publisher Plugin
to save the files as jenkins report.

Using as Token Macro Replacement Provider

Having installed the Token Macro Plugin (which will be the case, as it is a dependency of this plugin), following macros for replacement are provided automatically:

  • GITCHANGELOGJIRA: will output the JIRA Filter URL
  • GITCHANGELOG: will output a basic changelog, similar to git log.

If you use these macros in any plugin supporting token macro replacements, this will be replaced with either the Jira URL or the changelog.

The Email-ext plugin supports token macros, so you can include this URL
in an automatic release mail.

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.

 

Here is an example that creates the changelog in the summary of the job.

node {
 deleteDir()

 stage('Clone repo') {
  sh "git clone https://github.com/tomasbjerre/git-changelog-lib.git ."
 }
 
 step([$class: 'GitChangelogRecorder',
 config: [
 untaggedName: 'Unreleased',
 noIssueName: 'No issue',
 useReadableTagName: true,
 readableTagName: '/([^/]+?)$',
 
 useGitHub: true,
 gitHubApi: 'https://api.github.com/repos/tomasbjerre/git-changelog-lib',
 
 useJira: true,
 jiraIssuePattern: '\\bJENKINS-([0-9]+)\\b',
 
 fromReference: '',
 fromType: 'firstCommit',
 toReference: '',
 toType: 'master',
 
 showSummary: true,
 showSummaryUseTemplateContent: true,
 showSummaryTemplateContent: '''<h1> Git Changelog Lib changelog </h1>

<p>
Changelog of Git Changelog Lib.
</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}}
 <hr/>
{{/tags}}
'''
]])
}

 

And here is an example creating a file in the workspace. With commits between two other commits.

node {
 deleteDir()

 stage('Clone repo') {
  sh """
   git clone https://github.com/tomasbjerre/git-changelog-lib.git
   cd git-changelog-lib
   git log
   """
 }
 
 step([$class: 'GitChangelogRecorder',
 config: [
 useSubDirectory: true,
 subDirectory: 'git-changelog-lib',
     
 untaggedName: 'Unreleased',
 noIssueName: 'No issue',
 useReadableTagName: true,
 readableTagName: '/([^/]+?)$',
 
 useGitHub: true,
 gitHubApi: 'https://api.github.com/repos/tomasbjerre/git-changelog-lib',
 
 useJira: true,
 jiraIssuePattern: '\\bJENKINS-([0-9]+)\\b',
 
 fromReference: '46d37d70e2f9ffe1bb256ad853fd72d87169032e',
 fromType: 'commit',
 toReference: 'e37c36d2145414b6e7ce40a83e5818e03679a21d',
 toType: 'commit',

 useFile: true,
 file: 'thechangelog.html',
 createFileUseTemplateContent: true,
 createFileTemplateContent: '''<h1> Git Changelog Lib changelog </h1>

<p>
Changelog of Git Changelog Lib.
</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}}
 <hr/>
{{/tags}}
'''
]])

archiveArtifacts artifacts: '**/thechangelog.html'
}


Job DSL

Here is a sample job DSL.

freeStyleJob('Git Changelog Job') {
  scm {
    git {
      remote {
        name('origin')
        url('https://github.com/tomasbjerre/git-changelog-lib.git')
      }
    }
  }
  publishers {
    gitChangelogRecorder {
      config {
        fromType("commit")
        fromReference("20aca44")
        toType("ref")
        toReference("master")

        showSummary(true)
        showSummaryUseTemplateContent(true)
        showSummaryTemplateContent("""
<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}}
        """)


        useMediaWiki(true)
        mediaWikiUseTemplateContent(true)
        mediaWikiTemplateContent("""
__NOTOC__

= Git Changelog changelog =
Changelog of Git Changelog.

{{#tags}}
== {{name}} ==
 {{#issues}}
  {{#hasIssue}}
   {{#hasLink}}
=== {{name}} [{{link}} {{issue}}] {{title}} ===
   {{/hasLink}}
   {{^hasLink}}
=== {{name}} {{issue}} {{title}} ===
   {{/hasLink}}
  {{/hasIssue}}
  {{^hasIssue}}
=== {{name}} ===
  {{/hasIssue}}

   {{#commits}}
[https://github.com/tomasbjerre/git-changelog-lib/commit/{{hash}} {{hash}}] {{authorName}} {{commitTime}}

'''{{{messageTitle}}}'''

{{#messageBodyItems}}
 * {{.}} 
{{/messageBodyItems}}

  {{/commits}}

 {{/issues}}
{{/tags}}
        """)
        mediaWikiTitle("PRNFB Changelog")
        mediaWikiUrl("http://web:80/w")
        mediaWikiUsername(null)
        mediaWikiPassword(null)
        mediaWikiUseTemplateFile(false)
        mediaWikiTemplateFile(null)
        
        useGitHub(true)
        gitHubApi("https://api.github.com/repos/tomasbjerre/git-changelog-lib")
        gitHubIssuePattern(null)
        gitHubToken(null)
        gitHubApiTokenCredentialsId(null)
        useGitHubApiTokenCredentials(false)

        useReadableTagName(true)
        readableTagName("/([^/]+?)\$")

        configFile(null)
        createFileTemplateContent(null)
        createFileTemplateFile(null)
        createFileUseTemplateContent(false)
        createFileUseTemplateFile(false)
        customIssues {}
        dateFormat(null)
        file(null)
        useGitLab(false)
        gitLabServer(null)
        gitLabProjectName(null)
        gitLabToken(null)
        ignoreCommitsIfMessageMatches(null)
        ignoreCommitsWithoutIssue(false)
        ignoreTagsIfNameMatches(null)
        jiraIssuePattern(null)
        jiraPassword(null)
        jiraServer(null)
        jiraUsername(null)
        jiraUsernamePasswordCredentialsId(null)
        useJiraUsernamePasswordCredentialsId(false)
        noIssueName(null)
        showSummaryTemplateFile(null)
        showSummaryUseTemplateFile(false)
        subDirectory(null)
        timeZone(null)
        untaggedName(null)
        useConfigFile(false)
        useFile(false)
        useIgnoreTagsIfNameMatches(false)
        useJira(false)
        useSubDirectory(false)
        gitLabApiTokenCredentialsId(null)
        useGitLabApiTokenCredentials(false)
      }
    }
  }
}

Changelog

https://github.com/jenkinsci/git-changelog-plugin/blob/master/CHANGELOG.md

Development

See README.md at https://github.com/paulwellnerbou/git-changelog-jenkins-plugin

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

ArchivesGet past versions
Labels