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

Not able to retrieve the short commit id from multiple repositories on windows slave node.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Not A Defect
    • Icon: Major Major
    • git-plugin
    • None

      I want the short commit id of all the git repositories on windows slave node. I have done the following in my Jenkinsfile :
       checkout([$class: 'GitSCM', branches: [[name: "develop"]], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption', disableSubmodules: true, parentCredentials: false, recursiveSubmodules: true, reference: '', trackingSubmodules: false], [$class: 'RelativeTargetDirectory', relativeTargetDir: '']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '***', url: "GITURL"]]])
      {{}}
      checkout([$class: 'GitSCM', branches: [[name: 'master']], doGenerateSubmoduleConfigurations: false, extensions: [[$class: 'SubmoduleOption', disableSubmodules: true, parentCredentials: false, recursiveSubmodules: true, reference: '', trackingSubmodules: false], [$class: 'RelativeTargetDirectory', relativeTargetDir: 'XYZ']], submoduleCfg: [], userRemoteConfigs: [[credentialsId: '***', url: "GITURL1"]]])
      So after the after first checkout GITURL repository ( branch - develop) is getting downloaded in the jenkins workspace under job name folder on windows slave node and after the second checkout,GITURL1 repository (branch - master) is getting downloaded inside the same job name folder under the folder - XYZ. I want to capture the short commit id for both the repositories.

      I have written the following command to capture the short commit id.
       def SHORT_COMMIT_ID = bat (returnStdout: true, script: "@git log -n 1 --pretty=format:'%%h'").trim()
      echo 'Commit id ' + "$SHORT_COMMIT_ID"
      def SHORT_COMMIT_ID_XYZ = bat (returnStdout: true, script: "@git log -n 1 --pretty=format:'%%h' – XYZ").trim()
      echo 'XYZ Commit id ' + "$SHORT_COMMIT_ID_XYZ"
      for first commit id value is getting returned correctly. but for XYZ commit id getting blank value.

            markewaite Mark Waite
            shavasth Shubham Avasthi
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: