Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I build on specific commit in Git on Jenkins?

Tags:

I am trying to build my project from a specific commit, in Jenkins.

I have specified the branch to build and it's building from the HEAD commit.

However I want to build from any specific revision/commit.

I tried passing a GIT_COMMIT value as a parameter but it's picking up the HEAD commit only.

I also tried using svn type thing like https://svn-url@$REVISION where REVISION is parameter passed in build.

For git it doesn't recognize ssh://git-url@REVISION.

like image 828
virendrao Avatar asked Sep 20 '16 08:09

virendrao


2 Answers

  1. Jenkins Git plugin should be
  2. Copy your commit hash and paste it into "Branch Specifier"

enter image description here Then Run "Build now"

like image 118
Gleb Egunov Avatar answered Sep 25 '22 13:09

Gleb Egunov


Well I think instead of hacking the build config to point to a specific commit hash, it would be better to just create a new branch, that points to the commit you want to build. If you have a correctly configured Multibranch Pipeline Build, Jenkins should discover and build your commit/branch automatically.

Alternatively you could also use a tag instead of a branch. But in this case you need to add the "Discover tags" Behaviour to your Branch Source Config.

Branch Source Behaviours

like image 36
Daniel Rothmaler Avatar answered Sep 23 '22 13:09

Daniel Rothmaler