ref := client.Host().Directory(config.GitURL()).AsGit().Head()
dir = ref.Tree()
commit, err = ref.Commit(ctx)
Will work on a local machine on a fully cloned repo
But on Jenkins after a shallow clone will fail with
15 : GitRef.commit: String!
18 : │ git symbolic-ref HEAD
18 : │ [0.0s] | fatal: ref HEAD is not a symbolic ref
18 : │ git symbolic-ref HEAD ERROR [0.0s]
18 : │ ! git error: exit status 128
stderr:
fatal: ref HEAD is not a symbolic ref
The recommended git tool is: NONE
using credential jenkins-instance
Fetching changes from the remote Git repository
Using shallow fetch with depth 1
> git rev-parse --resolve-git-dir /var/lib/jenkins/workspace/some-project-template_master@3/some-project-template/.git # timeout=10
> git config remote.origin.url https://github.com/some-org/some-project-template.git # timeout=10
Fetching upstream changes from https://github.com/some-org/some-project-template.git
> git --version # timeout=10
> git --version # 'git version 2.43.0'
using GIT_ASKPASS to set credentials GitHub App
> git fetch --no-tags --force --progress --depth=1 -- https://github.com/some-org/some-project-template.git +refs/heads/master:refs/remotes/origin/master # timeout=10
Checking out Revision 51523dc48df459c867c31e477ba17235d1ad6a0b (master)
Commit message: "Merge pull request #557 from some-org/renovate/master-patch"
> git config core.sparsecheckout # timeout=10
> git checkout -f 51523dc48df459c867c31e477ba17235d1ad6a0b # timeout=10