2

I use How to configure Git post commit hook from gitlab to notify Jenkins of a new commit like:

https://jenkins.company.com/git/notifyCommit?url=project:Project.git

which works just fine.

However, if the test cases do not fail on master branch I want to release a new version (git tag & change some version in a file & push). This re-triggers the aforementioned webhook.

Is it possible to have Jenkins only re-trigger the build if built by a certain user?

Community
  • 1
  • 1
Georg Heiler
  • 16,916
  • 36
  • 162
  • 292

2 Answers2

1

Maybe you should separate the development branch and the master branch? I.e. have developer push commits to develop, set Jenkins to build develop and push to master after testing. This way you should not end up in a build loop (and the separate branch will make it easier to work with tested code).

Florian Castellane
  • 1,197
  • 2
  • 14
  • 38
0

For now this will be our solution

stage 'Checkout' checkout scm echo "My branch is: ${env.BRANCH_NAME}" echo "GIT commit is:" sh ' git log -1' // Jenkins does not support it any better: https://issues.jenkins-ci.org/browse/JENKINS-26133 sh 'git log -1 --pretty=%aE > commandResult' result = readFile('commandResult').trim() if("jenkins@faktorzehn.at" == result){ echo 'STOP pipeline to prevent infinite loop' error 'STOP to prevent infinite loop' }

Georg Heiler
  • 16,916
  • 36
  • 162
  • 292