title: Changed Environment Variable not reflecting inside the shell in Jenkins Pipeline
body: <p>In Jenkins, I tried to set a environment variable with a empty value, and in stages I will update the value of the variable. but the shell script failed to get the latest value and the old value is echo.</p>
  
  <pre><code>pipeline {
          agent {
              label 'test'
          } 
          tools {
              jdk 'Java 1.8'
          }
         environment {
               DASHBOARD_PATH = '/pkg/vddfg/oradfg/apache/htdocs/'
               COMMIT_ID = ' '
               GROUP_ID = 'Dashboard3'
               ARTIFACT_ID = 'MS_CSD_DB3'
               MS_VERSION = ' '
               JAVA_HOME = tool('Java 1.8')
               PATH="${JAVA_HOME}/bin:${env.PATH}"
          }   
          stages {
              stage('SCM CheckOut'){
                  steps {
                      checkout([$class: 'GitSCM', branches: [[name: '*/master']], doGenerateSubmoduleConfigurations: false, extensions: [], gitTool: 'default (git from PATH)', submoduleCfg: [], userRemoteConfigs: [[credentialsId: '9754f1e7-7095-4f68-bf56-6e92a292a241', url: 'git@demucvtr13:csd/csd-dashboard3.git']]])
                      //def gitCommit = sh(returnStdout: true, script: 'git rev-parse HEAD').trim()
                      //sh 'echo ${gitCommit}'
                      script {
                      COMMIT_ID =  withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin:/pkg/vddfg/home/oradfg/csw/bin']){ sh(script: "git rev-parse HEAD", returnStdout: true).trim() }
                      echo  COMMIT_ID
  
                  }
              }
               }                 
           stage('Artifact Upload') {
                  steps {
                      script {
                              def now = new Date()
                              MS_VERSION = now.format("yyMMdd_HHmm", TimeZone.getTimeZone('GMT+1'))
                              echo "${COMMIT_ID}"
                              echo "${GROUP_ID}"
                              echo "${ARTIFACT_ID}"
                              echo "${MS_VERSION}"
                              withEnv(['PATH+EXTRA=/usr/sbin:/usr/bin:/sbin:/bin']) {
                                  sh '''
                                      commit_id="${COMMIT_ID}"
                                      grp_id="${GROUP_ID}"
                                      art_id="${ARTIFACT_ID}"
                                      ver_id="${MS_VERSION}"
                                      '''
                              }        
                      }
                  }   
              }
  
          }            
  }
  </code></pre>
  
  <p>Echo is working under script{}. But it is not working under sh {}. </p>