Georg Heiler
Georg Heiler

Reputation: 17694

Jenkins git commit notification configuration

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?

Upvotes: 2

Views: 2234

Answers (2)

Florian Castellane
Florian Castellane

Reputation: 1225

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).

Upvotes: 1

Georg Heiler
Georg Heiler

Reputation: 17694

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("[email protected]" == result){ echo 'STOP pipeline to prevent infinite loop' error 'STOP to prevent infinite loop' }

Upvotes: 0

Related Questions