[JIRA] (JENKINS-52511) Plugin not providing values for GIT_COMMITTER_NAME and GIT_AUTHOR_NAME

408 views
Skip to first unread message

imranrazakhan@gmail.com (JIRA)

unread,
Jul 12, 2018, 6:14:02 AM7/12/18
to jenkinsc...@googlegroups.com
imran khan created an issue
 
Jenkins / Bug JENKINS-52511
Plugin not providing values for GIT_COMMITTER_NAME and GIT_AUTHOR_NAME
Issue Type: Bug Bug
Assignee: Mark Waite
Components: git-plugin
Created: 2018-07-12 10:13
Priority: Major Major
Reporter: imran khan

I tried to extract   GIT_COMMIT and {{GIT_COMMITTER_NAME }}values in my declarative pipeline, I can get value for GIT_COMMIT but values for GIT_COMMITER_NAME is missing.

Following are steps to extract 

echo "Git Commit $GIT_COMMIT"
echo "Env Git Name ${env.GIT_COMMITTER_NAME}"
echo "Env Git Author Name ${env.GIT_AUTHOR_NAME}"
echo "Git Author Name $GIT_AUTHOR_NAME"
echo "Git Commiter Name $GIT_COMMITTER_NAME"

 

For env.GIT_COMMITTER_NAME its giving null

For $GIT_COMMITTER_NAME or $GIT_AUTHOR_NAME its throwing following error

groovy.lang.MissingPropertyException: No such property: GIT_AUTHOR_NAME for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:45)

 

Add Comment Add Comment
 
This message was sent by Atlassian JIRA (v7.10.1#710002-sha1:6efc396)

imranrazakhan@gmail.com (JIRA)

unread,
Jul 12, 2018, 6:16:02 AM7/12/18
to jenkinsc...@googlegroups.com
imran khan updated an issue
Change By: imran khan
I tried to extract   {{GIT_COMMIT and }} {{ GIT_COMMITTER_NAME }}
values in my declarative pipeline, I can get value for GIT_COMMIT but values for GIT_COMMITER_NAME is missing.


Following are steps to extract 

echo "Git Commit $GIT_COMMIT"
echo "Env Git Name ${env.GIT_COMMITTER_NAME}"
echo "Env Git Author Name ${env.GIT_AUTHOR_NAME}"
echo "Git Author Name $GIT_AUTHOR_NAME"
echo "Git Commiter Name $GIT_COMMITTER_NAME"

 

For  ${ env.GIT_COMMITTER_NAME } its giving null


For $GIT_COMMITTER_NAME or $GIT_AUTHOR_NAME its throwing following error

groovy.lang.MissingPropertyException: No such property: GIT_AUTHOR_NAME for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:45)

{{ }}

Global variable is also set

I verified on my machine

$ git config --global user.name
imran raza khan

 

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

unread,
Jul 12, 2018, 9:40:02 AM7/12/18
to jenkinsc...@googlegroups.com
Mark Waite updated an issue
Change By: Mark Waite
I tried to extract     {{GIT_COMMIT }} and  {{GIT_COMMITTER_NAME }} GIT_COMMITTER_NAME values in my declarative pipeline, I can get value for GIT_COMMIT but values for GIT_COMMITER_NAME is missing.


Following are steps to extract 
{noformat}
echo "Git Commit $GIT_COMMIT"
echo "Env Git Name ${env.GIT_COMMITTER_NAME}"
echo "Env Git Author Name ${env.GIT_AUTHOR_NAME}"
echo "Git Author Name $GIT_AUTHOR_NAME"
echo "Git Commiter Name $GIT_COMMITTER_NAME"
{noformat}
 

For ${env.GIT_COMMITTER_NAME} its giving null

For $GIT_COMMITTER_NAME or $GIT_AUTHOR_NAME its throwing following error

{noformat}
groovy.lang.MissingPropertyException: No such property: GIT_AUTHOR_NAME for class: groovy.lang.Binding
at groovy.lang.Binding.getVariable(Binding.java:63)
at org.jenkinsci.plugins.scriptsecurity.sandbox.groovy.SandboxInterceptor.onGetProperty(SandboxInterceptor.java:242)
at org.kohsuke.groovy.sandbox.impl.Checker$6.call(Checker.java:288)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:292)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at org.kohsuke.groovy.sandbox.impl.Checker.checkedGetProperty(Checker.java:268)
at com.cloudbees.groovy.cps.sandbox.SandboxInvoker.getProperty(SandboxInvoker.java:29)
at com.cloudbees.groovy.cps.impl.PropertyAccessBlock.rawGet(PropertyAccessBlock.java:20)
at WorkflowScript.run(WorkflowScript:45)

{ noformat } }

Global variable is also set

I verified on my machine

$ git config --global user.name
imran raza khan

 

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

unread,
Jul 12, 2018, 9:53:02 AM7/12/18
to jenkinsc...@googlegroups.com
Mark Waite commented on Bug JENKINS-52511
 
Re: Plugin not providing values for GIT_COMMITTER_NAME and GIT_AUTHOR_NAME

I believe you're making syntactic mistakes rather than missing the values of GIT_COMMITTER_NAME and GIT_AUTHOR_NAME. Refer to the example declarative pipeline job in my JENKINS-52511 branch for working examples.

The GIT_COMMITTER_NAME and GIT_AUTHOR_NAME in that example show that JENKINS-45489 is still an open bug. That bug reports that the value assigned to GIT_COMMITTER_NAME and GIT_AUTHOR_NAME is incorrect if a Pipeline shared library was loaded along with the working repository. The value assigned to GIT_COMMIT is the SHA-1 of the commit which declarative pipeline used in its implicit checkout. Unfortunately, the value assigned to GIT_AUTHOR_NAME and GIT_COMMITTER_NAME is from the most recent commit to the Pipeline shared library.

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

unread,
Jul 12, 2018, 9:55:03 AM7/12/18
to jenkinsc...@googlegroups.com
Mark Waite edited a comment on Bug JENKINS-52511
I believe you're making syntactic mistakes rather than missing the values of {{GIT_COMMITTER_NAME}} and {{GIT_AUTHOR_NAME}}.  Refer to the example declarative pipeline job in my [JENKINS-52511 branch|https://github.com/MarkEWaite/jenkins-bugs/blob/JENKINS-52511/Jenkinsfile] for working examples.


The GIT_COMMITTER_NAME and GIT_AUTHOR_NAME in that example show that JENKINS-45489 is still an open bug.  That bug reports that the value assigned to GIT_COMMITTER_NAME and GIT_AUTHOR_NAME is incorrect if a Pipeline shared library was loaded along with the working repository.  The value assigned to GIT_COMMIT is the SHA-1 of the commit which declarative pipeline used in its implicit checkout.  Unfortunately, the value assigned to GIT_AUTHOR_NAME and GIT_COMMITTER_NAME is from the most recent commit to the Pipeline shared library.


You might also refer to the related [Jenkins minute video|https://www.youtube.com/watch?v=tziVDpNYlgM].

imranrazakhan@gmail.com (JIRA)

unread,
Jul 12, 2018, 10:27:02 AM7/12/18
to jenkinsc...@googlegroups.com

I used your provided code in windows and following is output

just changed like below

ws(dir: WORKSPACE )

Started by user Imran Raza Khan
> git.exe rev-parse --is-inside-work-tree # timeout=10
Setting origin to https://my.com/scm/java/my.git
> git.exe config remote.origin.url https://my.com/scm/java/my.git # timeout=10
Fetching origin...
Fetching upstream changes from origin
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> git.exe fetch --tags --progress origin +refs/heads/:refs/remotes/origin/
Seen branch in repository origin/TEST-555
Seen branch in repository origin/TESTJENKINS
Seen branch in repository origin/master
Seen branch in repository origin/test
Seen 4 remote branches
Obtained Jenkinsfile from 6895d05d313977e329519d17c5074a0b334be8cf
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] node
Running on Jenkins in C:\Users\imran\.jenkins\workspace\e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A
[Pipeline] {
[Pipeline] stage
[Pipeline]

{ (Declarative: Checkout SCM) [Pipeline] checkout > git.exe rev-parse --is-inside-work-tree # timeout=10 Fetching changes from the remote Git repository > git.exe config remote.origin.url https://my.com/scm/java/my.git # timeout=10 Fetching without tags Fetching upstream changes from https://my.com/scm/java/my.git > git.exe --version # timeout=10 using GIT_ASKPASS to set credentials > git.exe fetch --no-tags --progress https://my.com/scm/java/my.git +refs/heads/*:refs/remotes/origin/* Checking out Revision 6895d05d313977e329519d17c5074a0b334be8cf (TESTJENKINS) > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f 6895d05d313977e329519d17c5074a0b334be8cf Commit message: "update Jenkins Pipeline WIP" > git.exe rev-list --no-walk 211e9cf1009aa872739b9c5d21289711c332d0af # timeout=10 [Pipeline] }

[Pipeline] // stage
[Pipeline] withEnv
[Pipeline] {
[Pipeline] stage
[Pipeline] { (parallel)
[Pipeline] parallel
[Pipeline] [windows] { (Branch: windows)
[Pipeline] [windows] stage
[Pipeline] [windows] { (windows)
[Pipeline] [windows] echo
[windows] pipeline GIT_COMMIT before windows ws is 6895d05d313977e329519d17c5074a0b334be8cf
[Pipeline] [windows] ws
[windows] Running in C:\Users\imran\.jenkins\workspace\e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A@2
[Pipeline] [windows]

{ [Pipeline] [windows] echo [windows] pipeline GIT_AUTHOR_NAME in windows ws is null [Pipeline] [windows] bat [windows] [e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A@2] Running batch script [windows] [windows] C:\Users\imran\.jenkins\workspace\e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A@2>echo bat GIT_COMMITTER_NAME in windows ws is [windows] bat GIT_COMMITTER_NAME in windows ws is [Pipeline] [windows] }

[Pipeline] [windows] // ws
[Pipeline] [windows] echo
[windows] pipeline GIT_COMMIT after windows ws is 6895d05d313977e329519d17c5074a0b334be8cf
[Pipeline] [windows] bat
[windows] [e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A] Running batch script
[windows]
[windows] C:\Users\imran\.jenkins\workspace\e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A>echo bat GIT_COMMIT after windows ws is 6895d05d313977e329519d17c5074a0b334be8cf
[windows] bat GIT_COMMIT after windows ws is 6895d05d313977e329519d17c5074a0b334be8cf
[Pipeline] [windows] bat
[windows] [e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A] Running batch script
[windows]
[windows] C:\Users\imran\.jenkins\workspace\e-multipipeline_TESTJENKINS-WB7B2SPPZGFQC74ER3V7H4MZCMM7MPKNLHALQPJ5OVCWHK3MYM7A>echo hello windows from IMRAN-118
[windows] hello windows from IMRAN-118
[Pipeline] [windows] }
[Pipeline] [windows] // stage
[Pipeline] [windows] }
[Pipeline] // parallel
[Pipeline] }
[Pipeline] // stage
[Pipeline] }
[Pipeline] // withEnv
[Pipeline] }
[Pipeline] // node
[Pipeline] End of Pipeline
Finished: SUCCESS

imranrazakhan@gmail.com (JIRA)

unread,
Jul 12, 2018, 10:28:02 AM7/12/18
to jenkinsc...@googlegroups.com
imran khan edited a comment on Bug JENKINS-52511
I used your provided code in windows and following is output

just changed like below

ws(dir: WORKSPACE )

*OUTPUT:*

Started by user Imran Raza Khan
> git.exe rev-parse --is-inside-work-tree # timeout=10
Setting origin to
[ https://my.com/scm/java/my.git ]
> git.exe config remote.origin.url
[ https://my.com/scm/java/my.git ]
# timeout=10

Fetching origin...
Fetching upstream changes from origin
> git.exe --version # timeout=10
using GIT_ASKPASS to set credentials
> git.exe fetch --tags --progress origin +refs/heads/*:refs/remotes/origin/*

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

unread,
Jul 12, 2018, 12:20:02 PM7/12/18
to jenkinsc...@googlegroups.com

That output is not at all unreasonable based on JENKINS-45489.

If your goal is to determine the author name or committer name of the commit which is the HEAD of the current repository, then you'll need to use a technique like I've illustrated in the JENKINS-52511/Jenkinsfile.

There are earlier bug reports which reminded me that the meaning of GIT_COMMITTER_NAME in a Freestyle job may not be what people are expecting. A 2013 comment in JENKINS-20386 hints that the GIT_COMMITTER_NAME in Freestyle jobs means "the name that will be used for any commits from this repository". In that context at that time, it did not mean "the name of the committer of the most recent commit in the working directory".

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

unread,
Jul 13, 2018, 4:44:01 PM7/13/18
to jenkinsc...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages