0

With Jenkins git plugin, you have options for branch, url and credentials. How do I pass the revision (SHA1), in order to checkout a particular revision of the branch? https://wiki.jenkins.io/display/JENKINS/Git+Plugin

Thanks.

user518066
  • 981
  • 1
  • 15
  • 23
  • I found https://stackoverflow.com/questions/43611673/jenkins-pipeline-checkout-explicit-git-commit. This worked using checkout. – user518066 Feb 28 '19 at 15:18

1 Answers1

0

In general, you can't. The plugin will always fetch and check out references, not commits.

Fetching specific commits by SHA1 is a relatively new feature (see Retrieve specific commit from a remote Git repository); it is not even support by all repository servers.

If you're sure that the SHA1 exists on the branch that has been fetched, then you're free to git reset the working copy in a build step. However, you'd mess with a git clone that's maintained by the git plugin -- so I recommend to take care of the entire clone/fetch/checkout step yourself, not using the git plugin.

Alex O
  • 6,259
  • 2
  • 20
  • 37