Could it be that this is the solution? http://stackoverflow.com/questions/42798006/how-to-disable-automatic-build-from-scm-change-in-jenkinsfile The flow in my case is:
PR to GHE > GHE sends pull_request webhook to Jenkins > Jenkins uses the Jenkinsfile to run unit tests > Jenkins makes a call to merge the PR to the master branch. The merge to the master branch is essentially a push webhook, so: GHE sends a push webhook to Jenkins > Jenkins uses the same Jenkinsfile to run again unit tests > there is logic to not-merge in case the branch is the master branch > Instead publish to npm > bump the version number > commit & push to git. This time because the the whole thing worked from a checkout of the master branch and not based on a PR, the option to "Suppress automatic SCM triggering" should hopefully stop the loop from starting... On Thursday, March 23, 2017 at 4:09:09 PM UTC+2, Idan Adar wrote: > > Unfortunately I am not versed enough in programming to add this > functionality... > > I think that the workaround will add lots of "red rows" in the job view, > because it first has to checkout the repo, check the messages and then > abort... > > On Thursday, March 23, 2017 at 3:59:07 PM UTC+2, Mark Waite wrote: >> >> The git plugin as used in pipeline doesn't support ignoring commits from >> certain users, or ignoring commits with certain messages. Until it does, >> you will probably need to "short circuit" and exit from the pipeline after >> using git commands to extract the latest commit message from the >> repository. It's not a pretty solution, but it can work now. >> >> Another alternative is to fork the git plugin and add the "ignore commits >> from specific user" support to the pipeline. >> >> Mark Waite >> >> On Thu, Mar 23, 2017 at 7:43 AM Idan Adar <[email protected]> wrote: >> >>> I should add that the job is of multibranch type. >>> >>> >>> On Thursday, March 23, 2017 at 3:10:51 PM UTC+2, Idan Adar wrote: >>>> >>>> Hi all, >>>> >>>> In a declarative pipeline (a Jenkinsfile in the repo), how can I stop a >>>> job from getting re/triggered due to a push event in GitHub? >>>> For example: >>>> >>>> stage ("Publish to npm") { >>>> steps { >>>> sh ''' >>>> npm publish >>>> npm --no-git-tag-version version minor >>>> ''' >>>> >>>> sh ''' >>>> git commit -am 'Bumped version number' >>>> git push >>>> ''' >>>> } >>>> } >>>> >>>> The "git push" will trigger the push webhook in GitHub that makes a >>>> call to Jenkins, which will in turn start the same Jenkinsfile and again >>>> bump the version, commit, push and again... a loop. >>>> How can we not-trigger the job in this scenario? >>>> >>>> >>>> -- >>> You received this message because you are subscribed to the Google >>> Groups "Jenkins Users" group. >>> To unsubscribe from this group and stop receiving emails from it, send >>> an email to [email protected]. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/jenkinsci-users/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com >>> >>> <https://groups.google.com/d/msgid/jenkinsci-users/af0d3836-ae98-4e09-93bf-9dfa4d65b39f%40googlegroups.com?utm_medium=email&utm_source=footer> >>> . >>> For more options, visit https://groups.google.com/d/optout. >>> >> -- You received this message because you are subscribed to the Google Groups "Jenkins Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/jenkinsci-users/2eb19e36-0fee-45e8-b347-a11f3ff64577%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.
