Okay so it does look like a bug then ,raised 3 years ago and it's not
just me doing something stupid with my setup, configuration or
Jenkinsfile.

I was already doing the hardcoded workaround in the Jenkinsfile, but
then spotted the "Custom user name/e-mail address" option so wanted to
switch to that so it was no longer hard coded in the Jenkinsfile but
controlled by the Jenkins job.

I was even fine with having to add this to each Jenkinsfile to work
around it not setting local git config.

sh '''
git config user.email "${GIT_COMMITTER_EMAIL}"
git config user.name "${GIT_COMMITTER_NAME}"
'''

John

On Tue, 25 Aug 2020 at 23:52, Mark Waite <[email protected]> wrote:
>
> It looks as though the environment variables that the git plugin is trying to 
> set are not visible to later shell steps.  See  
> https://issues.jenkins-ci.org/browse/JENKINS-46052 for a work around using a 
> shell command to define the user name and email address for the git committer.
>
> On Tue, Aug 25, 2020 at 4:22 PM John Patrick <[email protected]> wrote:
>>
>> So adding sh 'printenv' I don't see any GIT_ environment variables and
>> in the config.xml I've got it set as;
>>
>> <jenkins.plugins.git.traits.UserIdentityTrait>
>> <extension class="hudson.plugins.git.extensions.impl.UserIdentity">
>> <name>aName</name>
>> <email>[email protected]</email>
>> </extension>
>> </jenkins.plugins.git.traits.UserIdentityTrait>
>>
>> Anything else I should check, or anything else I need to configure to
>> get this working?
>>
>> John
>>
>> On Tue, 25 Aug 2020 at 10:43, John Patrick <[email protected]> wrote:
>> >
>> > On Tue, 25 Aug 2020 at 00:56, Mark Waite <[email protected]> wrote:
>> > >
>> > >
>> > >
>> > > On Mon, Aug 24, 2020 at 5:29 PM John Patrick <[email protected]> 
>> > > wrote:
>> > >>
>> > >> Might be a question for developers or a bug ticket.
>> > >>
>> > >> I've got a multibranchPipelineJob project which runs a Jenkinsfile. The 
>> > >> job executes as expected apart form one part.
>> > >>
>> > >> If I select "Configure remote name" and change it to "origin1". When I 
>> > >> do "sh 'git remote -v'". I see as expected;
>> > >>
>> > >> [Pipeline] sh +
>> > >> git remote -v
>> > >> origin1 REPO (fetch)
>> > >> origin1 REPO (push)
>> > >> [Pipeline] sh
>> > >>
>> > >> But If I do "Custom user name/e-mail address" and enter say "aName" and 
>> > >> "[email protected]". When I do "sh 'git config --list'". I don't see 
>> > >> user.name or user.email set, I just see;
>> > >>
>> > >> [Pipeline] sh +
>> > >> git config --list
>> > >> core.repositoryformatversion=0
>> > >> core.filemode=true
>> > >> core.bare=false
>> > >> core.logallrefupdates=true
>> > >> remote.origin1.url=REPO
>> > >> remote.origin1.fetch=+refs/heads/*:refs/remotes/origin1/*
>> > >> [Pipeline] sh
>> > >>
>> > >> According to the documentation I should be seeing user.name and 
>> > >> user.email set here. Just wondering if it's a bug, a bug with 
>> > >> multibranch pipeline job, or I'm missing a step in my Jenkinsfile.
>> > >>
>> > >
>> > > It is a bug in the documentation.  The documentation say one thing (sets 
>> > > config) while the code does something better (sets the environment 
>> > > variable GIT_COMMITTER_NAME and GIT_AUTHOR_NAME).  Documentation fix was 
>> > > merged today and should be visible within the next 24 hours at 
>> > > https://plugins.jenkins.io/git/#custom-user-name-e-mail-address
>> > >
>> >
>> > Thanks for the reply, I can see the documentation talking about
>> > GIT_COMMITTER_NAME and GIT_AUTHOR_NAME. Might seem a silly question
>> > but how should I be accessing these environment variables from a
>> > Jenkinsfile?
>> >
>> > As I can echo BUILD_ID but not GIT_COMMITTER_NAME, e.g.
>> >
>> > sh ' echo "BUILD_ID=${BUILD_ID}"'
>> >
>> > give me;
>> > [Pipeline] sh
>> > + echo BUILD_ID=22
>> > BUILD_ID=22
>> >
>> > but;
>> > sh ' echo "GIT_COMMITTER_NAME=${GIT_COMMITTER_NAME}"'
>> >
>> > give me;
>> > [Pipeline] sh (hide)
>> > + echo GIT_COMMITTER_NAME=
>> > GIT_COMMITTER_NAME=
>> >
>> > I've tried ${env.GIT_COMMITTER_NAME} but that give "bad substitution"
>> >
>> > I've tried;
>> > sh ' echo "GIT_COMMITTER_NAME="' + GIT_COMMITTER_NAME
>> >
>> > But that gives;
>> > [Pipeline] End of Pipeline
>> > groovy.lang.MissingPropertyException: No such property:
>> > GIT_COMMITTER_NAME for class: groovy.lang.Binding
>> > at groovy.lang.Binding.getVariable(Binding.java:63)
>> >
>> > Do I have to wait for another jenkins release as your reply implied I
>> > didn't as it was just a documentation issue and I was using the
>> > wrong...
>> >
>> > Or am I simply using the wrong syntax to access these environment
>> > variables or missed some setup for the Jenkinsfile.
>> >
>> > cheers,
>> > John
>> >
>> > >
>> > > 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 [email protected].
>> > > To view this discussion on the web visit 
>> > > https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtGUPhbQd0O%3D%2B9TYU-Vy5jr7QqquMQWu2vorgX15MG8kjw%40mail.gmail.com.
>>
>> --
>> 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 [email protected].
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/jenkinsci-users/CAH9u10nhOb42mNaC6g-Vk6SoE4a9kGohXuaHa0HDHjHhihNP2Q%40mail.gmail.com.
>
> --
> 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 [email protected].
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/jenkinsci-users/CAO49JtHCgPG92K1saFtAxEh7yrXjvKZd_baPOcgXsDkTzeXNpA%40mail.gmail.com.

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/jenkinsci-users/CAH9u10mXaqSt7QMLnSAxK%3DTGpX22_vPTZCgBF2XEjHr-2GEvWA%40mail.gmail.com.

Reply via email to