Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-43563

Git plugin does not set user in pipeline

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Open (View Workflow)
    • Priority: Major
    • Resolution: Unresolved
    • Component/s: git-plugin
    • Labels:
      None
    • Similar Issues:

      Description

      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.

        Attachments

          Activity

          Hide
          markewaite Mark Waite added a comment -

          Michael Düsterhus I'm happy to receive a pull request with automated tests that show the problem and a code change that fixes the tests. Thanks for your interest in helping the Jenkins project!

          Show
          markewaite Mark Waite added a comment - Michael Düsterhus I'm happy to receive a pull request with automated tests that show the problem and a code change that fixes the tests. Thanks for your interest in helping the Jenkins project!
          Hide
          apr_1985 Adam Roberts added a comment -

          I have added a Warning on the https://wiki.jenkins.io/display/JENKINS/Git+Plugin page as I too wasted time trying to debug this issue.

          Show
          apr_1985 Adam Roberts added a comment - I have added a Warning on the https://wiki.jenkins.io/display/JENKINS/Git+Plugin page as I too wasted time trying to debug this issue.
          Hide
          mwyraz Michael michael@wyraz.de added a comment -

          Is it possible to access these settings programmatically in the pipeline?

          Show
          mwyraz Michael michael@wyraz.de added a comment - Is it possible to access these settings programmatically in the pipeline?
          Hide
          mwyraz Michael michael@wyraz.de added a comment - - edited

          Update: it is possible through the scm variable. So my workaround is:

          					def scmvars=steps.checkout(globals.scm)
          					if (scmvars.GIT_AUTHOR_NAME && scmvars.GIT_AUTHOR_EMAIL) {
          						steps.sh(script:"""
          							git config user.name '${scmvars.GIT_AUTHOR_NAME}'
          							git config user.email '${scmvars.GIT_AUTHOR_EMAIL}'
          							""")
          					}
          
          Show
          mwyraz Michael michael@wyraz.de added a comment - - edited Update: it is possible through the scm variable. So my workaround is: def scmvars=steps.checkout(globals.scm) if (scmvars.GIT_AUTHOR_NAME && scmvars.GIT_AUTHOR_EMAIL) { steps.sh(script:""" git config user.name '${scmvars.GIT_AUTHOR_NAME}' git config user.email '${scmvars.GIT_AUTHOR_EMAIL}' """) }
          Hide
          kwin Konrad Windszus added a comment -

          The workaround from above is not working though if only global git settings are used (not the per project behaviour). The according environment variables are not set if in that case.

          Show
          kwin Konrad Windszus added a comment - The workaround from above is not working though if only global git settings are used (not the per project behaviour). The according environment variables are not set if in that case.

            People

            • Assignee:
              Unassigned
              Reporter:
              chrylis Christopher Smith
            • Votes:
              10 Vote for this issue
              Watchers:
              16 Start watching this issue

              Dates

              • Created:
                Updated: