[JIRA] (JENKINS-52490) Plugin should provide GIT_COMMIT_MESSAGE as Environment Variable

5 views
Skip to first unread message

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 11, 2018, 3:49:01 PM7/11/18
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
 
Jenkins / New Feature JENKINS-52490
Plugin should provide GIT_COMMIT_MESSAGE as Environment Variable
Change By: Mark Waite
Summary: Plugin should provide GIT_COMMITTER_MESSAGE GIT_COMMIT_MESSAGE as Enviornment Environment Variable
Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 11, 2018, 4:17:01 PM7/11/18
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
Change By: Mark Waite
Summary: Plugin should provide GIT_COMMITTER_MESSAGE GIT_COMMIT_MESSAGE as Environment Variable

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 11, 2018, 4:18:02 PM7/11/18
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on New Feature JENKINS-52490
 
Re: Plugin should provide GIT_COMMIT_MESSAGE as Environment Variable
This is already available for Pipeline jobs by using the {{GIT_COMMIT}} (sha1 of the commit) value returned in the map of the {{checkout}} step.  Use that SHA1 to call
a shell step and read the commit message into your Pipeline.

{noformat}
    branch = 'JENKINS-50401'
    checkout_result = checkout([$class: 'GitSCM',
                branches: [[name: branch]],
                extensions: [[$class: 'CloneOption', honorRefspec: true, noTags: true],
                     [$class: 'LocalBranch', localBranch: branch]
                     ],
                userRemoteConfigs: [[refspec: "+refs/heads/${branch}:refs/remotes/origin/${branch}",
                     url: 'https://github.com/MarkEWaite/jenkins-bugs.git']]])
    commit_message = sh returnStdout: true, script: "git log -n 1 ${checkout_result.GIT_COMMIT)"
{noformat}

If that same information is needed in a Freestyle project, you'll need to use a similar technique from within the build script.

imranrazakhan@gmail.com (JIRA)

unread,
Jul 12, 2018, 11:43:01 AM7/12/18
to jenkinsc...@googlegroups.com

Till the time we didnt get GIT_COMMIT_MESSAGE, Following step will work in declarative jenkins piepline

GIT_MESSAGE = powershell (returnStdout: true, script: 'git log -1 --format=%B ${GIT_COMMIT}').trim()

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 12, 2018, 12:40:03 PM7/12/18
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on New Feature JENKINS-52490
This is already available for Pipeline jobs by using the {{GIT_COMMIT}} (sha1 of the commit) value returned in the map of the {{checkout}} step.  Use that SHA1 to call a shell step and read the commit message into your Pipeline.

{noformat}
    branch = 'JENKINS-50401'
    checkout_result = checkout([$class: 'GitSCM',
                branches: [[name: branch]],
                extensions: [[$class: 'CloneOption', honorRefspec: true, noTags: true],
                     [$class: 'LocalBranch', localBranch: branch]
                     ],
                userRemoteConfigs: [[refspec: "+refs/heads/${branch}:refs/remotes/origin/${branch}",
                     url: 'https://github.com/MarkEWaite/jenkins-bugs.git']]])
    commit_message = sh ( returnStdout: true, script: "git log -n 1 ${checkout_result.GIT_COMMIT)" )
{noformat}

If that same information is needed in a Freestyle project, you'll need to use a similar technique from within the build script.

mark.earl.waite@gmail.com (JIRA)

unread,
Jul 12, 2018, 12:41:01 PM7/12/18
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on New Feature JENKINS-52490
This is already available for Pipeline jobs by using the {{GIT_COMMIT}} (sha1 of the commit) value returned in the map of the {{checkout}} step.  Use that SHA1 to call a shell step and read the commit message into your Pipeline.

{noformat}
    branch = 'JENKINS-50401'
    checkout_result = checkout([$class: 'GitSCM',
                branches: [[name: branch]],
                extensions: [[$class: 'CloneOption', honorRefspec: true, noTags: true],
                     [$class: 'LocalBranch', localBranch: branch]
                     ],
                userRemoteConfigs: [[refspec: "+refs/heads/${branch}:refs/remotes/origin/${branch}",
                     url: 'https://github.com/MarkEWaite/jenkins-bugs.git']]])
    commit_message = sh(returnStdout: true, script: "git log -n 1 ${checkout_result.GIT_COMMIT ) } ")

{noformat}

If that same information is needed in a Freestyle project, you'll need to use a similar technique from within the build script.

knurek.j@gmail.com (JIRA)

unread,
Dec 11, 2019, 7:00:02 AM12/11/19
to jenkinsc...@googlegroups.com
J Knurek commented on New Feature JENKINS-52490

I've had a try at implemented what is needed for this feature. I actually haven't tested it, or added any unit tests, because I'm not even sure this is a valid approach. So I'd appreciate some feedback on the PR before continuing: https://github.com/jenkinsci/git-plugin/pull/796

This message was sent by Atlassian Jira (v7.13.6#713006-sha1:cc4451f)
Atlassian logo

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 11, 2019, 12:29:02 PM12/11/19
to jenkinsc...@googlegroups.com

I am piv vacation for the rest of this week. Other maintainers may be available, but I am not.

I generally don't accept pull requests that lack tests. However, I'm willing to recite for direction before tests are written

mark.earl.waite@gmail.com (JIRA)

unread,
Dec 21, 2019, 10:24:03 AM12/21/19
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on New Feature JENKINS-52490
I am piv vacation for 've reviewed and commented on the rest of this week [pull request|https://github . Other maintainers may be available, but I am not.

I generally don't accept
com/jenkinsci/git-plugin/ pull requests that lack tests /796] . However, I'm willing to recite for direction before tests are written
Reply all
Reply to author
Forward
0 new messages