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

GIT_COMMITTER_NAME not added for CpsFlowDefinition

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • git-plugin, pipeline
    • None
    • Jenkins 2.319.3
      Git plugin 4.10.3
      Pipeline 2.6
      Pipeline: SCM Step 2.13

      When defining a pipeline through "Pipeline Script" (org.jenkinsci.plugins.workflow.cps.CpsFlowDefinition) we don't get the all the GIT_* environment variables we usually get when defining the same pipeline through "Pipeline Script from SCM" (org.jenkinsci.plugins.workflow.cps.CpsScmFlowDefinition).

      I have defined the following defaults through an init.d scripts:

      def desc = Jenkins.instance.getDescriptor('hudson.plugins.git.GitSCM')
      desc.setGlobalConfigName('Jenkins CI')
      desc.setGlobalConfigEmail('*redacted*')
      

       

      Then, I defined a basic pipeline for tests:

      pipeline {
        agent any
        stages {
          stage('Test GIT') {
            steps{
              sh 'env | sort | grep GIT'
            }
          }
        }
      }
      

       

      If I use this pipeline as is (CpsFlowDefinition), I get the following result:

      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test GIT)
      [Pipeline] sh
      + env
      + sort
      + grep GIT
      DEFAULT_GIT_URL=/git
      JENKINS_CREDS_GIT_PASSWORD=*redacted*
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // node

       

      If I use this pipeline in a Jenkinsfile in a Git repository (CpsScmFlowDefinition), I get that: 

      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Declarative: Checkout SCM)
      [Pipeline] checkout
      The recommended git tool is: git
      using credential jenkins
       > git rev-parse --resolve-git-dir /var/jenkins_home/workspace/test-git-job/.git # timeout=10
      Fetching changes from the remote Git repository
       > git config remote.origin.url /git/infra/my-repo # timeout=10
      Fetching upstream changes from /git/infra/my-repo
       > git --version # timeout=10
       > git --version # 'git version 2.30.2'
      using GIT_SSH to set credentials 
       > git fetch --tags --force --progress -- /git/infra/my-repo +refs/heads/*:refs/remotes/origin/* # timeout=10
       > git rev-parse origin/master^{commit} # timeout=10
      Checking out Revision 875b4edc2b269186d6394b72d9fc7f0392d475b4 (origin/master)
       > git config core.sparsecheckout # timeout=10
       > git checkout -f 875b4edc2b269186d6394b72d9fc7f0392d475b4 # timeout=10
      Commit message: "check GIT_"
       > git rev-list --no-walk 875b4edc2b269186d6394b72d9fc7f0392d475b4 # timeout=10
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] withEnv
      [Pipeline] {
      [Pipeline] stage
      [Pipeline] { (Test GIT)
      [Pipeline] sh
      + env
      + sort
      + grep GIT 
      DEFAULT_GIT_URL=/git
      GIT_AUTHOR_EMAIL=*redacted*
      GIT_AUTHOR_NAME=Jenkins CI
      GIT_BRANCH=origin/master
      GIT_COMMIT=875b4edc2b269186d6394b72d9fc7f0392d475b4
      GIT_COMMITTER_EMAIL=*redacted*
      GIT_COMMITTER_NAME=Jenkins CI
      GIT_PREVIOUS_COMMIT=875b4edc2b269186d6394b72d9fc7f0392d475b4
      GIT_PREVIOUS_SUCCESSFUL_COMMIT=875b4edc2b269186d6394b72d9fc7f0392d475b4
      GIT_URL=/git/infra/my-repo
      JENKINS_CREDS_GIT_PASSWORD=*redacted*
      [Pipeline] }
      [Pipeline] // stage
      [Pipeline] }
      [Pipeline] // withEnv
      [Pipeline] }
      [Pipeline] // node
      

       

      There is this withEnv step that I don't understand (can that explain the difference in behaviour ?)

      The issue with these not being defined is that if the pipeline tries to commit things we get the following error

      *** Please tell me who you are.
      
      Run
      
        git config --global user.email "you@example.com"
        git config --global user.name "Your Name"
      

       

      Is this an expected difference in behaviour or rather a bug ?

            markewaite Mark Waite
            glatapoui Joel
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: