gowtham rajeevswaroop
gowtham rajeevswaroop

Reputation: 55

How to get the git latest commit message in jenkins and apply regular expressions on it to find needed data?

i need to build a job in Jenkins, to get latest git commit message every time a commit is done and to store it in a variable.Can anyone suggest a plugin or a way to do this?

Upvotes: 0

Views: 10736

Answers (2)

Iurii Perevertailo
Iurii Perevertailo

Reputation: 2707

Need to analyze a currentBuild.changeSets. Full answer in another stackoverflow topic. Also, you can read a doc here

Upvotes: 1

Oron Golan
Oron Golan

Reputation: 371

Use command line and get the commit message that you want and create a file as key value and inject the variable:

Step by step:

  1. Install git plugin, EnvInject Plugin.

  2. Get the last git commit by the command git log -p -1 and parse from that what you need.

  3. Create a file as key value for example LAST_COMMIT_ID=cab123gfbdak

  4. Use the envInject as file (this load the key value file that you created to Jenkins as Jenkins variable).

Good luck.

Upvotes: 2

Related Questions