Git Commit Message as an Environment Variable

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Git Commit Message as an Environment Variable

Jeremy Hartley-2
Hi,

I'm playing around a bit with Git environment variables to send to slack and would like to include the Git commit message. I don't see it available in the list here: https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables

Is there any way to send the Git commit message to slackSend as an environment variable in my pipeline?

Thanks

Jeremy

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/65afed35-7011-4f3c-84e0-41b196b3a5a3%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Git Commit Message as an Environment Variable

Daniel Beck-2
I have a (never released) plugin that integrates with the Jenkins changelog that does something like this: https://github.com/daniel-beck/changelog-environment-plugin

If you know enough Maven to build a plugin, this might work. The problem there is that the Jenkins built-in changelog doesn't handle PRs/branches well: The first builds always have no changelogs (since there's no reference to compare them to).

But I expect it's easier and more reliable to just call e.g. git show --no-patch --format='format:%s%n%n%b' and use its output (with some extra work to get around merge commits and such, depending on exactly what you want).

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAMo7Pt%2B-mkD_y_R%2Bhe2G%3DOd5CqgyrWfq9tZfZ450nWnedwjbOw%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Git Commit Message as an Environment Variable

eric.boehm
In reply to this post by Jeremy Hartley-2
You could use groovy to collect the commit message from the ChangeSet and then put it in an environment variable.

On Tuesday, November 19, 2019 at 9:53:52 AM UTC-5, Jeremy Hartley wrote:
Hi,

I'm playing around a bit with Git environment variables to send to slack and would like to include the Git commit message. I don't see it available in the list here: <a href="https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGit%2BPlugin%23GitPlugin-Environmentvariables\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyCwpUoFaIeUftXGari0MuGGCsyg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGit%2BPlugin%23GitPlugin-Environmentvariables\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyCwpUoFaIeUftXGari0MuGGCsyg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables

Is there any way to send the Git commit message to slackSend as an environment variable in my pipeline?

Thanks

Jeremy

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Git Commit Message as an Environment Variable

Mark Waite-2
If it helps, I have an example that iterates over the changeset provided for a Pipeline job when running on a branch within a multibranch pipeline.

I believe it is limited to multibranch pipelines, but have not checked to be sure.

On Wed, Nov 20, 2019 at 3:44 PM 'Eric Boehm' via Jenkins Users <[hidden email]> wrote:
You could use groovy to collect the commit message from the ChangeSet and then put it in an environment variable.

On Tuesday, November 19, 2019 at 9:53:52 AM UTC-5, Jeremy Hartley wrote:
Hi,

I'm playing around a bit with Git environment variables to send to slack and would like to include the Git commit message. I don't see it available in the list here: https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables

Is there any way to send the Git commit message to slackSend as an environment variable in my pipeline?

Thanks

Jeremy

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com.


--
Thanks!
Mark Waite

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtEh2o-0bOHLnHMrvKkUOTfwfA_7Z0TN5TeQksMX5D%2BXSQ%40mail.gmail.com.
Reply | Threaded
Open this post in threaded view
|

Re: Git Commit Message as an Environment Variable

Jeremy Hartley
Thanks Mark and Eric. I'll give this suggestion a try

On Thursday, November 21, 2019 at 12:37:44 AM UTC+1, Mark Waite wrote:
If it helps, I have an example that <a href="https://github.com/MarkEWaite/jenkins-bugs/blob/873e78402ca3cc2fc2330020cba8794274b2077a/Jenkinsfile#L56" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMarkEWaite%2Fjenkins-bugs%2Fblob%2F873e78402ca3cc2fc2330020cba8794274b2077a%2FJenkinsfile%23L56\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFfmeJ4D25ejy8xbJCQ8prrnL85Bg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fgithub.com%2FMarkEWaite%2Fjenkins-bugs%2Fblob%2F873e78402ca3cc2fc2330020cba8794274b2077a%2FJenkinsfile%23L56\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFfmeJ4D25ejy8xbJCQ8prrnL85Bg&#39;;return true;">iterates over the changeset provided for a Pipeline job when running on a branch within a multibranch pipeline.

I believe it is limited to multibranch pipelines, but have not checked to be sure.

On Wed, Nov 20, 2019 at 3:44 PM 'Eric Boehm' via Jenkins Users <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="msv5H5zGBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com> wrote:
You could use groovy to collect the commit message from the ChangeSet and then put it in an environment variable.

On Tuesday, November 19, 2019 at 9:53:52 AM UTC-5, Jeremy Hartley wrote:
Hi,

I'm playing around a bit with Git environment variables to send to slack and would like to include the Git commit message. I don't see it available in the list here: <a href="https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGit%2BPlugin%23GitPlugin-Environmentvariables\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyCwpUoFaIeUftXGari0MuGGCsyg&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwiki.jenkins.io%2Fdisplay%2FJENKINS%2FGit%2BPlugin%23GitPlugin-Environmentvariables\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyCwpUoFaIeUftXGari0MuGGCsyg&#39;;return true;">https://wiki.jenkins.io/display/JENKINS/Git+Plugin#GitPlugin-Environmentvariables

Is there any way to send the Git commit message to slackSend as an environment variable in my pipeline?

Thanks

Jeremy

--
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 <a href="javascript:" target="_blank" gdf-obfuscated-mailto="msv5H5zGBwAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">jenkins...@googlegroups.com.
To view this discussion on the web visit <a href="https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com?utm_medium=email&amp;utm_source=footer" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;" onclick="this.href=&#39;https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com?utm_medium\x3demail\x26utm_source\x3dfooter&#39;;return true;">https://groups.google.com/d/msgid/jenkinsci-users/a0b485ff-8f48-4432-be5b-8a2d6af600a4%40googlegroups.com.


--
Thanks!
Mark Waite

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/04714215-d3de-4b2b-84a4-8aefdedd2ddc%40googlegroups.com.
Reply | Threaded
Open this post in threaded view
|

Re: Git Commit Message as an Environment Variable

Victor Martinez
In reply to this post by Jeremy Hartley-2
If GitHub is the provider there is an inprogress PR to support it:
https://github.com/jenkinsci/pipeline-github-plugin/pull/65

Although I have not gone further to add some UTs yet though.

--
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 [hidden email].
To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/6b85d44f-b408-4c74-a52e-f1a13abdf395%40googlegroups.com.