Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Trigger a Jenkins Build based on Commit Author?

Tags:

git

jenkins

The team I work on has 4 developers. The desired workflow is for each developer to have their own jenkins project and for any branch they push to, to trigger a build. It doesn't look like it's possible from the Git plugin, and there doesn't seem to be a way to select a branch based on the set of commit authors. It seems like we could come up with magic branch names and trigger each team member's project based on the branch name, but a branch might be passed around to multiple developers to work on a large issue.

like image 502
Thtu Avatar asked Dec 06 '25 07:12

Thtu


2 Answers

There is an option in the Git plugin to do the opposite = exclude a list of users:

enter image description here

As your team is quite small (4 developers), you can exclude 3 developers in order to build the commits of the 4th one.

like image 160
Bruno Lavit Avatar answered Dec 08 '25 22:12

Bruno Lavit


It seems you are looking for a combination of:

git-show-ref

  $ git show-ref [--hash]
  528ea2bb0d2f9dbf166bcefce2aba34cf53cdf4d [refs/heads/branch]
  a3a5a0d105729c19dfea0aa09a8c8a19a9d65262 [refs/heads/master]

and:

git-log

for each of the branches:

  (master)$ git log [--author|--committer]=... --pretty="%H"
  a3a5a0d105729c19dfea0aa09a8c8a19a9d65262
  18c4c551a935cfa42189fc48f83273a3290c96b0
  86fd09697424a72bbece451bc6bdab54cee61794
  d7aaab0f4d4055bc541284b723edb111c55b3e95

  (branch)$ git log [--author|--committer]=... --pretty="%H"
  528ea2bb0d2f9dbf166bcefce2aba34cf53cdf4d
  d7aaab0f4d4055bc541284b723edb111c55b3e95

And, tadaaa, here's git-reflog:

(master)$ git reflog [--author|--committer]=... --pretty="%H [%gd]" --branches -<no of branches>
a3a5a0d105729c19dfea0aa09a8c8a19a9d65262 [master@{0}]
528ea2bb0d2f9dbf166bcefce2aba34cf53cdf4d [branch@{0}]
like image 44
Gerold Broser Avatar answered Dec 08 '25 23:12

Gerold Broser