jenkinsci/git-changelog-plugin

How to add change log in email using this plugin coperating with email-ext-plugin

Closed this issue · 16 comments

When I launch a build, I can see the changes in Jenkins.

Could I use this git-changelog-plugin to add changes in email?

image

I'm also wondering how to do this. I've got the token ${GITCHANGELOG} in my email content body for the Editable Email Notification and a post-build action of "Git Changelog" with specific commit references (full SHA1's, not VARS) and on the job summary page I see all the changes, but I keep getting the error message in the email body:

No revs given, searching automatically for latest released tags... Found toRev tag $TAG2 Found fromRev tag $NEW_TAG Commits between $NEW_TAG and $TAG2:

@tomasbjerre @paulwellnerbou help?

@furystryker, @Gongzelong: Sure, this is possible.

This part of the plugin is designed for release changelogs, so it searches automatically for logs between tags. But if you provide the correct hashs (you can find them in your jenkins build environment), you should be able to get the log since the last build.

I don't know which variables are provided there in memory, I'll look into this later today and come back to you then.

@Gongzelong: Sorry for the late reply, this issue passed my attention somehow until now. :-/

I've been over both of those docs in the past 24h to no avail.

Is there a way to pass fromRev or toRev directly to GITCHANGELOG ?

What about this configuration?
screenshot from 2017-02-17 12-46-49

If not, you can just use ${CHANGES_SINCE_LAST_BUILD} (although there seem to be a bug now, but will be fixed soon: https://issues.jenkins-ci.org/browse/JENKINS-38668)

I've been using the hash's, but even when I use the ENV VAR's the email still comes in blank, I can see the changes on the changes screen for the jobs though, either way.

Hopefully the screenshots will help clarify

screen shot 2017-02-17 at 9 21 53 am
screen shot 2017-02-17 at 9 20 27 am

screen shot 2017-02-16 at 9 52 31 am

screen shot 2017-02-16 at 9 52 18 am
screen shot 2017-02-16 at 9 52 05 am

@furystryker There are two changes detected since the latest build, numbered with 1. and 2. Just the commit messages are not displayed. Can you paste an output of the git log between those revisions to have a look at the git commit messages? Are they empty?

Could you have a look at the build log? The complete output of "publish git changelog" is printed to console as well.

By the way, you don't need both tasks, just use one of them, the one which suites you better. "Git changelog" is way more flexible, so I assume this might fit better for your use. "Publish git changelog" is build to automatically search diffs between releases/tags, to create automatic release mails.

Marked

I face the same problem.
I've set "From reference"=${GIT_PREVIOUS_COMMIT} and "To reference"=${GIT_COMMIT}.
I do see correct changelog on build result page. But ${GITCHANGELOG} inside the email I see "No revs given, searching automatically for latest released tags... Found toRev tag..."

I did set the variables inside the git publish section. But not sure how to set the same in the editable email notification parts to get an emal.
The document shared above are not helpful.

I would use a pipeline. There are examples in the readme. Create the changelog, store it in a variable and use that variable when constructing email content.

Here is how to send email from pipeline: https://jenkins.io/doc/pipeline/steps/email-ext/

Hi Tomas,

I was trying to generate a pipeline code from snippet generator for gitChangelog. There I can find many fields which are not explained much.
Like what I should specify for value?
Where can I find GitHub Token and API url?

Hi Tomas,

I tried to get the change logs in the variable and call it in the email. But I did not get any email notification.
Am I missing something in the code?

node {
 deleteDir()
 sh """
 git clone git@github.com:Myrepository/testing.git .
 """

 def changelogString = gitChangelog returnType: 'STRING',
  from: [type: 'REF', value: 'sumith08-patch-1'], #from my local repo
  to: [type: 'REF', value: 'master'], #to Master repo
  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/Myrepository/testing/commit/{{hash}}">{{hash}}</a> {{authorName}} <i>{{commitTime}}</i>
<p>
<h3>{{{messageTitle}}}</h3>

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


  {{/commits}}

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

mail bcc: '', body: """Here is the changelog:

${changelogString}
""", cc: '', from: '', replyTo: '', subject: 'The Changelog', to: 'sumith.waghmare@gmail.com'
}

I think it looks correct. Perhaps you did not configure emailing correctly in Jenkins. But this is not the place to ask such things, try Stackoverflow. Maby https://stackoverflow.com/questions/45760348/how-to-send-email-notification-with-jenkins