• Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: Major Major
    • git-plugin
    • None

      It's been noted in other issues (JENKINS-35230) that the Git plugin does not export its environment variables when used with a pipeline job. In addition, the plugin does not set user.name and user.email, as it does in traditional jobs, meaning that any attempts to commit to the repository from within a pipeline fail with "tell me who you are".

      It would be useful to have the environment variables available, but even without them, the plugin should be able to set the Git config as it performs checkout.

          [JENKINS-43563] Git plugin does not set user in pipeline

          Christopher Smith created issue -

          Mark Waite added a comment -

          There is a global setting for user.name and user.email in the global settings for the git plugin. Have you defined a value there and still not had the user.name and user.mail set on the agents?

          Mark Waite added a comment - There is a global setting for user.name and user.email in the global settings for the git plugin. Have you defined a value there and still not had the user.name and user.mail set on the agents?
          Mark Waite made changes -
          Assignee Original: Mark Waite [ markewaite ]

          Will Jenkins added a comment - - edited

          Hi - I am getting the same issue. I have set the global settings for user.name and user.email for the git plugin but I am seeing the following when I make a commit in a pipeline:

          Your name and email address were configured automatically based
          on your username and hostname. Please check that they are accurate.
          You can suppress this message by setting them explicitly. Run the
          following command and follow the instructions in your editor to edit
          your configuration file:
          
              git config --global --edit
          
          After doing this, you may fix the identity used for this commit with:
          
              git commit --amend --reset-author
          

          I have also tried running the command above to edit the text file holding the values on the build server itself, but to no avail. I have also attempted to update the values directly using 

          git config --global user.name "Jenkins Build Server"
          

          but still no joy, just getting the same message.

          Will Jenkins added a comment - - edited Hi - I am getting the same issue. I have set the global settings for user.name and user.email for the git plugin but I am seeing the following when I make a commit in a pipeline: Your name and email address were configured automatically based on your username and hostname. Please check that they are accurate. You can suppress this message by setting them explicitly. Run the following command and follow the instructions in your editor to edit your configuration file: git config --global --edit After doing this , you may fix the identity used for this commit with: git commit --amend --reset-author I have also tried running the command above to edit the text file holding the values on the build server itself, but to no avail. I have also attempted to update the values directly using  git config --global user.name "Jenkins Build Server" but still no joy, just getting the same message.

          Flo Pic added a comment -

          Hi,

          I also have the same problem, i've tried with "Additional Behaviours Custom user name/e-mail address" but still the same error ...

          Have you found a solution?

          Flo Pic added a comment - Hi, I also have the same problem, i've tried with "Additional Behaviours Custom user name/e-mail address" but still the same error ... Have you found a solution?

          Mark Waite added a comment -

          Inserting an sh or bat step after the checkout and prior to the first command that performs a commit should be enough. Something like this:

          sh 'git config user.name Your.Name'
          sh 'git config user.email your.address@example.com'
          

          Those two commands will define git user name and git email address in that repository (and only in that repository).

          Mark Waite added a comment - Inserting an sh or bat step after the checkout and prior to the first command that performs a commit should be enough. Something like this: sh 'git config user.name Your.Name' sh 'git config user.email your.address@example.com' Those two commands will define git user name and git email address in that repository (and only in that repository).

          Lei JIANG added a comment -

          It that possible to prioritise this issue please. 

          Lei JIANG added a comment - It that possible to prioritise this issue please. 

          Mark Waite added a comment - - edited

          leijiang please use the workaround described in the comment prior to your request. Because there is an easy work around, this will not be investigated further by me.

          Mark Waite added a comment - - edited leijiang please use the workaround described in the comment prior to your request. Because there is an easy work around, this will not be investigated further by me.

          Sorry this is not acceptable.
          The documentation in https://plugins.jenkins.io/git clearly states that the plugin will do the user and email configuration. Do you know how much hours developers waste to find out that something that should work out of the box needs workarounds?
          We have pipelines with more then 10 git checkouts where updates get pushed, so the pipeline scripts gets totally ugly.

          Michael Düsterhus added a comment - Sorry this is not acceptable. The documentation in https://plugins.jenkins.io/git clearly states that the plugin will do the user and email configuration. Do you know how much hours developers waste to find out that something that should work out of the box needs workarounds? We have pipelines with more then 10 git checkouts where updates get pushed, so the pipeline scripts gets totally ugly.

          Daniel Beck added a comment -

          The documentation

          It's sourced from a wiki page linked in the sidebar, everyone with an account can edit it. Users frequently contribute to that, and the changes are of varying quality. I'm sure Mark would appreciate your help in improving the quality of the documentation.

          Daniel Beck added a comment - The documentation It's sourced from a wiki page linked in the sidebar, everyone with an account can edit it. Users frequently contribute to that, and the changes are of varying quality. I'm sure Mark would appreciate your help in improving the quality of the documentation.

            Unassigned Unassigned
            chrylis Christopher Smith
            Votes:
            17 Vote for this issue
            Watchers:
            23 Start watching this issue

              Created:
              Updated: