Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-45814

"Suppress automatic SCM triggering" prevents push notifications

    XMLWordPrintable

Details

    Description

      When I add the branch property "Suppress automatic SCM triggering" (which was introduced with JENKINS-32396) to a multi-branch pipeline job, then it does not react on push notifications at all anymore.

      It does suppress the trigger of a build after branch indexing, as expected. But if I setup a jenkins hook e.g. in stash/Bitbucket it does also swallow all my pushes. If I push a new branch or a change to an existing branch no build is triggered.

      I would expect in this case a build starts, and only if a branch is detected during indexing t get suppressed.

      If I'm not mistaken the code should be here (and looks actually good to me):

      https://github.com/jenkinsci/branch-api-plugin/blob/master/src/main/java/jenkins/branch/NoTriggerBranchProperty.java#L69

       

      Attachments

        Issue Links

          Activity

            since it is same (or even less) effort as doing our own plugin

            I think you'll quickly find that updating your patched version is more work than just creating a simple plugin that has your impl...

            stephenconnolly Stephen Connolly added a comment - since it is same (or even less) effort as doing our own plugin I think you'll quickly find that updating your patched version is more work than just creating a simple plugin that has your impl...
            sag47 Sam Gleske added a comment - - edited

            I experience this with the GitHub branch source plugin within multibranch pipelines. I nearly created a new issue but then found this.

            So, what's the best course of action here? "Suppress automatic scm triggering" blocks GitHub push triggers. Should I create a new plugin, add to an existing plugin (like the scm-filter-branch-pr plugin), or file a new bug report for this plugin?

            sag47 Sam Gleske added a comment - - edited I experience this with the GitHub branch source plugin within multibranch pipelines. I nearly created a new issue but then found this. So, what's the best course of action here? "Suppress automatic scm triggering" blocks GitHub push triggers. Should I create a new plugin, add to an existing plugin (like the scm-filter-branch-pr plugin), or file a new bug report for this plugin?

            sag47 Good question.  I am in the same boat here.  If we restart our stateless jenkins server - I dont like the idea of scanning for all branches, and everything being rebuilt.

            carpnick2 Nick Carpenter added a comment - sag47 Good question.  I am in the same boat here.  If we restart our stateless jenkins server - I dont like the idea of scanning for all branches, and everything being rebuilt.
            sbb_wzu MWZ-WZU SBB added a comment -

            We have the exact same issue. (Stateless jenkins server)

            Did anyone find a solution for this? We try to avoid writing and maintaining our own plugins.

            sbb_wzu MWZ-WZU SBB added a comment - We have the exact same issue. (Stateless jenkins server) Did anyone find a solution for this? We try to avoid writing and maintaining our own plugins.

            Hi,

            it's not entirely w/o maintenance but we kinda hotfixed the plugin by adding this class (which basically globally suppresses the build on BranchIndexingCause):

            /*
             * The MIT License
             *
             * Copyright 2016 CloudBees, Inc.
             *
             * Permission is hereby granted, free of charge, to any person obtaining a copy
             * of this software and associated documentation files (the "Software"), to deal
             * in the Software without restriction, including without limitation the rights
             * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
             * copies of the Software, and to permit persons to whom the Software is
             * furnished to do so, subject to the following conditions:
             *
             * The above copyright notice and this permission notice shall be included in
             * all copies or substantial portions of the Software.
             *
             * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
             * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
             * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
             * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
             * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
             * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
             * THE SOFTWARE.
             */
            
            package jenkins.branch;
            
            import hudson.Extension;
            import hudson.model.*;
            import org.kohsuke.accmod.Restricted;
            import org.kohsuke.accmod.restrictions.NoExternalUse;
            import org.kohsuke.stapler.DataBoundConstructor;
            
            import java.util.List;
            
            /**
             * Suppresses builds due to {@link BranchIndexingCause}
             */
            @Restricted(NoExternalUse.class)
            public class SuppressIndexingBuildsBranchProperty extends BranchProperty {
            
                @DataBoundConstructor
                public SuppressIndexingBuildsBranchProperty() {}
            
                @Override
                public <P extends Job<P, B>, B extends Run<P, B>> JobDecorator<P, B> jobDecorator(Class<P> clazz) {
                    return null;
                }
            
                @Extension
                public static class DescriptorImpl extends BranchPropertyDescriptor {
            
                    @Override
                    public String getDisplayName() {
                        return Messages.NoTriggerBranchProperty_suppress_automatic_scm_triggering();
                    }
            
                }
            
                @Extension
                public static class Dispatcher extends Queue.QueueDecisionHandler {
            
                    @SuppressWarnings({"unchecked", "rawtypes"}) // untypable
                    @Override
                    public boolean shouldSchedule(Queue.Task p, List<Action> actions) {
                        for (Action action :  actions) {
                            if (action instanceof CauseAction) {
                                for (Cause c : ((CauseAction) action).getCauses()) {
                                    if (c instanceof BranchIndexingCause) {
                                        return false;
                                    }
                                }
                            }
                        }
                        return true;
                    }
            
                }
            
            }

             

            We added these steps in our jenkins master rollout process:

            curl -sfL https://github.com/jenkinsci/branch-api-plugin/archive/branch-api-${branchApiVersion}.tar.gz | tar xvz
            cd branch-api-plugin-branch-api-${branchApiVersion}
            cp ../SuppressIndexingBuildsBranchProperty.java src/main/java/jenkins/branch/SuppressIndexingBuildsBranchProperty.java
            mvn -V -B compile hpi:hpi
            cp -v target/branch-api.hpi ${jenkinsPluginDirectory}

             

            Hope this helps,

            Thomas

             

            schneidexe Thomas Schneider added a comment - Hi, it's not entirely w/o maintenance but we kinda hotfixed the plugin by adding this class (which basically globally suppresses the build on BranchIndexingCause): /* * The MIT License * * Copyright 2016 CloudBees, Inc. * * Permission is hereby granted, free of charge, to any person obtaining a copy * of this software and associated documentation files (the "Software" ), to deal * in the Software without restriction, including without limitation the rights * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell * copies of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included in * all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS" , WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN * THE SOFTWARE. */ package jenkins.branch; import hudson.Extension; import hudson.model.*; import org.kohsuke.accmod.Restricted; import org.kohsuke.accmod.restrictions.NoExternalUse; import org.kohsuke.stapler.DataBoundConstructor; import java.util.List; /** * Suppresses builds due to {@link BranchIndexingCause} */ @Restricted(NoExternalUse.class) public class SuppressIndexingBuildsBranchProperty extends BranchProperty { @DataBoundConstructor public SuppressIndexingBuildsBranchProperty() {} @Override public <P extends Job<P, B>, B extends Run<P, B>> JobDecorator<P, B> jobDecorator( Class <P> clazz) { return null ; } @Extension public static class DescriptorImpl extends BranchPropertyDescriptor { @Override public String getDisplayName() { return Messages.NoTriggerBranchProperty_suppress_automatic_scm_triggering(); } } @Extension public static class Dispatcher extends Queue.QueueDecisionHandler { @SuppressWarnings({ "unchecked" , "rawtypes" }) // untypable @Override public boolean shouldSchedule(Queue.Task p, List<Action> actions) { for (Action action : actions) { if (action instanceof CauseAction) { for (Cause c : ((CauseAction) action).getCauses()) { if (c instanceof BranchIndexingCause) { return false ; } } } } return true ; } } }   We added these steps in our jenkins master rollout process: curl -sfL https: //github.com/jenkinsci/branch-api-plugin/archive/branch-api-${branchApiVersion}.tar.gz | tar xvz cd branch-api-plugin-branch-api-${branchApiVersion} cp ../SuppressIndexingBuildsBranchProperty.java src/main/java/jenkins/branch/SuppressIndexingBuildsBranchProperty.java mvn -V -B compile hpi:hpi cp -v target/branch-api.hpi ${jenkinsPluginDirectory}   Hope this helps, Thomas  

            People

              stephenconnolly Stephen Connolly
              schneidexe Thomas Schneider
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: