How do I create a release number in Jenkins from a Git tag?

How can I set Jenkins build version based on Git tag?

What I am doing now:

  • Use the Maven versions plugin to set the release version of the current build from Jenkins build number eg. newVersion = 1.1. $ BUILD_NUMBER
  • Building and deploying a project with Maven
  • Use Git Publisher to tag a build in Git using build number eg. MYPROJECT_BUILD-1,1. $ BUILD_NUMBER

What I would like to do: Instead of using Jenkins' BUILD_NUMBER, I would like to extract the latest build number from the Git tag and increment it

  • Get the last tag from Git that matches a given pattern, for example MYPROJECT_BUILD -. *
  • Extract the build number from the tag and increment it
  • Building and deploying a project with Maven
  • Use Git Publisher to tag a construct in Git using an appended line number, e.g. MYPROJECT_BUILD-1.1.124

What is the best way to achieve this?

+3


source to share


1 answer


Git doesn't know about Maven. Is there a specific reason why Git should enumerate?

Maven is IMHO the best choice. It knows about your source of control (if you've configured it correctly <scm>

) and knows what a version is and if it's a release or a snapshot.



With the Maven + Git + Jenkins combination, we are very happy with the Release Plugin : it takes your snapshot, makes a Maven release and flags it in Git, and navigates to the next snapshot (you define that version number).

+1


source







All Articles