HI,
Could you help how to identify and resolve this issue please.
I'm trying to get last commit id from a git repo as part of Jenkins > Jenkinsfile
# Below is the complete output from jenkins console. (I masked few data)
Started by user USER1 (External)
Rebuilds build #284
Checking out git [email protected]:MYORG/myrepo.git into /data/jenkins_home/workspace/common/build_myrepo@script to read Jenkinsfile
using credential svc-account
> git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repository
> git config remote.origin.url [email protected]:MYORG/myrepo.git # timeout=10
Cleaning workspace
> git rev-parse --verify HEAD # timeout=10
Resetting working tree
> git reset --hard # timeout=10
> git clean -fdx # timeout=10
Fetching upstream changes from [email protected]:MYORG/myrepo.git
> git --version # timeout=10
using GIT_SSH to set credentials Service Accounts private Github SSH key
> git fetch --tags --progress [email protected]:MYORG/myrepo.git +refs/heads/*:refs/remotes/origin/* # timeout=10
> git rev-parse refs/remotes/origin/JIRA-1234^{commit} # timeout=10
> git rev-parse refs/remotes/origin/refs/heads/JIRA-1234^{commit} # timeout=10
Checking out Revision f1151c631e43f5f41b303a9a99f1fabcbdb6b498 (refs/remotes/origin/JIRA-1234)
> git config core.sparsecheckout # timeout=10
> git checkout -f f1151c631e43f5f41b303a9a99f1fabcbdb6b498 # timeout=10
Commit message: "update"
> git rev-list --no-walk 2d265a7fb2315ed81883f901eda035bcc68e6119 # timeout=10
Running in Durability level: MAX_SURVIVABILITY
[Pipeline] Start of Pipeline
[Pipeline] node
Running on Jenkins in /data/jenkins_home/workspace/common/build_myrepo
[Pipeline] {
[Pipeline] sh
+ echo /data/jenkins_home/workspace/common/build_myrepo
[Pipeline] {
[Pipeline] stage
[Pipeline] { (Pre Build Stage)
[Pipeline] sh
+ pwd
/data/jenkins_home/workspace/common/build_myrepo
+ echo 'Executing git log --format=%H -n 1'
Executing git log --format=%H -n 1
++ git log --format=%H -n 1
fatal: bad default revision 'HEAD'
+ latestGitCommitId=
[Pipeline] }
[Pipeline] / stage
[Pipeline] sh
+ echo [email protected]
[Pipeline] echo
Preparing notification for a successful build
[Pipeline] emailext
Sending email to: [email protected]
[Pipeline] }
[Pipeline] / withCredentials
[Pipeline] }
[Pipeline] / node
[Pipeline] End of Pipeline
ERROR: script returned exit code 128
Finished: FAILURE
Open in new window