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

Poll SCM and Timer triggers include "Changes" for a Pipeline for any/all Shared Libraries

    • Pipeline - July/August

      I noticed this while filing another ticket (JENKINS-41496), but the "Changes" view for the Pipeline run for this project "azure" has the "wrong commits" shown. See the screenshots for more.

      What basically appears to be happening is that any change to a Shared Library will result in newly triggered Pipelines which have "Poll SCM" configured. Pipelines which configure a timer will also have Changes from the Shared Library listed when it executes again.

      I think listing the Shared Library commits in "Changes" is acceptable, but triggering based on an SCM Poll for a Pipeline is very confusing behavior and IMHO incorrect behavior.

      As a shared tooling team, I would not expect my Shared Library changes to trigger a bunch of Pipelines for projects depending on them.

          [JENKINS-41497] Poll SCM and Timer triggers include "Changes" for a Pipeline for any/all Shared Libraries

          Rich added a comment -

          I am facing similar issue. When I unselect 'Include @Library changes in job recent changes' and restart Jenkins, changelog does not show changes made to shared library but any change in shared library is still triggering the build.

          Rich added a comment - I am facing similar issue. When I unselect 'Include @Library changes in job recent changes' and restart Jenkins, changelog does not show changes made to shared library but any change in shared library is still triggering the build.

          dor s added a comment -

          I still can't find a way to disable the change log for the shared library changes (which is not relevant for me) in declerative pipelines

           

          is seems that the default is true

          apperantly thhis is the relevant code:

           

              private Boolean changelog = true;
              ...
              // default to including changes of the library in job recent changes
              @DataBoundSetter public void setChangelog(Boolean changelog) {
                  this.changelog = changelog;
              }

           

          https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java#L111-L114

           

          and this

           

              static void doRetrieve(String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception {
                  ...
                  delegate.setChangelog(changelog);

           

          https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/libs/SCMSourceRetriever.java#L139

           

          more info here: https://issues.jenkins.io/browse/JENKINS-41497?focusedCommentId=394574&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-394574

          dnusbaum any chance that you can have a look?

           

          dor s added a comment - I still can't find a way to disable the change log for the shared library changes (which is not relevant for me) in declerative  pipelines   is seems that the default is true apperantly thhis is the relevant code:   private Boolean changelog = true ; ... // default to including changes of the library in job recent changes @DataBoundSetter public void setChangelog( Boolean changelog) { this .changelog = changelog; }   https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/libs/LibraryStep.java#L111-L114   and this   static void doRetrieve( String name, boolean changelog, @Nonnull SCM scm, FilePath target, Run<?, ?> run, TaskListener listener) throws Exception { ... delegate.setChangelog(changelog);   https://github.com/jenkinsci/workflow-cps-global-lib-plugin/blob/master/src/main/java/org/jenkinsci/plugins/workflow/libs/SCMSourceRetriever.java#L139   more info here:  https://issues.jenkins.io/browse/JENKINS-41497?focusedCommentId=394574&page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#comment-394574 dnusbaum  any chance that you can have a look?  

          Philip Beadling added a comment - - edited

          I have the same issue in declarative pipeline with fresh install of 2.263.3.

          With a multibranch declarative pipeline (Bitbucket Source Plugin) my job changelog contains very confusingly Git revision changes for my global pipeline library (loaded via git scm), but lists no changes from Bitbucket.

          Following advice I have unticked:

            Include @Library changes in job recent changes

           

          And also tried changing my Jenkinsfile annotation to:

          @Library(value='my-lib', changelog=false)

           

          But neither prevents the details appearing on clicking on a the build page for a completed job.

          I get GIt revision details on every job run from the last library update - irrespective if the library has been updated from the last job or not.

           

          Also I note that the declarative way of loading a libraries - using the libraries directive has no provision for setting the changelog parameter, as evidenced by this note in the source code:

          https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/15978cd172a8d34e2cd6bf8a6bfeaa5514d44dad/pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy#L743

           

          As Bitbucket doesn't use polling I don't have the problem of my jenkins library kicking off builds.

           

          FWIW - I think both kicking off builds and even reporting library changes should be turned off by default, it's taken me a fair bit of head-scratching to even understand where the commit ids came from - I had just assumed they were from my project source control for months.

           

          Philip Beadling added a comment - - edited I have the same issue in declarative pipeline with fresh install of 2.263.3. With a multibranch declarative pipeline (Bitbucket Source Plugin) my job changelog contains very confusingly Git revision changes for my global pipeline library (loaded via git scm), but lists no changes from Bitbucket. Following advice I have unticked:   Include @Library changes in job recent changes   And also tried changing my Jenkinsfile annotation to: @Library(value='my-lib', changelog=false)   But neither prevents the details appearing on clicking on a the build page for a completed job. I get GIt revision details on every job run from the last library update - irrespective if the library has been updated from the last job or not.   Also I note that the declarative way of loading a libraries - using the libraries directive has no provision for setting the changelog parameter, as evidenced by this note in the source code: https://github.com/jenkinsci/pipeline-model-definition-plugin/blob/15978cd172a8d34e2cd6bf8a6bfeaa5514d44dad/pipeline-model-definition/src/main/groovy/org/jenkinsci/plugins/pipeline/modeldefinition/parser/ModelParser.groovy#L743   As Bitbucket doesn't use polling I don't have the problem of my jenkins library kicking off builds.   FWIW - I think both kicking off builds and even reporting library changes should be turned off by default, it's taken me a fair bit of head-scratching to even understand where the commit ids came from - I had just assumed they were from my project source control for months.  

          Tyler added a comment -

          My company recently moved from GitLab to GitHub and this exact issue is happening now where it triggers all consumers of our shared library. The problem is that we have such a large consumer base that it is literally triggering 100s of pipeline jobs. We have tried everything like others have mentioned with adding additional behaviours to the lib pipeline definition: "Don't trigger a build on commit notifications", "Polling ignored from certain users", "dot not check Include @Library changes in job recent changes" and nothing works. We are upgrading our Jenkins and plugins this weekend which is a little dated but I don't think it will resolve anything based on the open issues. I'm hoping some sort of solution is found because this is not ideal and we are having to do some creative things to get by at the moment 

          Tyler added a comment - My company recently moved from GitLab to GitHub and this exact issue is happening now where it triggers all consumers of our shared library. The problem is that we have such a large consumer base that it is literally triggering 100s of pipeline jobs. We have tried everything like others have mentioned with adding additional behaviours to the lib pipeline definition: "Don't trigger a build on commit notifications", "Polling ignored from certain users", "dot not check Include @Library changes in job recent changes" and nothing works. We are upgrading our Jenkins and plugins this weekend which is a little dated but I don't think it will resolve anything based on the open issues. I'm hoping some sort of solution is found because this is not ideal and we are having to do some creative things to get by at the moment 

          Rich added a comment -

          gartoty, I had similar issues. Try this:

          1. Did you restart Jenkins after you made changes to the Shared Library definition ? If not, do it now.
          2. All your pipeline jobs which are getting triggered, will need reset of 'GitHub hook trigger for GITScm polling' i.e. go to each job, disable the trigger, save job, enable the trigger, save job.

          That should fix. You may try #2 on a few jobs first before doing it for all 100s of them.

          Rich added a comment - gartoty , I had similar issues. Try this: Did you restart Jenkins after you made changes to the Shared Library definition ? If not, do it now. All your pipeline jobs which are getting triggered, will need reset of 'GitHub hook trigger for GITScm polling' i.e. go to each job, disable the trigger, save job, enable the trigger, save job. That should fix. You may try #2 on a few jobs first before doing it for all 100s of them.

          Richard added a comment -

          It is March 2023, five years after the bug was reported.
          I come here every time I update a global library, and Jenkins launches more than 100 projects, blocking the servers for hours.

          The fact that such a fundamental bug has not been fixed for such a long period of time frightens me every time and I think about a change of CI software.

          If it weren't for the 100+ pipelines, I wouldn't want to rewrite ....

          Richard added a comment - It is March 2023, five years after the bug was reported. I come here every time I update a global library, and Jenkins launches more than 100 projects, blocking the servers for hours. The fact that such a fundamental bug has not been fixed for such a long period of time frightens me every time and I think about a change of CI software. If it weren't for the 100+ pipelines, I wouldn't want to rewrite ....

          Bruce Coveny added a comment -

          debugbug - is this not solved by 'unchecking' the option for 'Include @Library changes in job recent changes' in the section 'Global Pipeline Libraries' under Manage Jenkins -> Configure?

           

          Bruce Coveny added a comment - debugbug - is this not solved by 'unchecking' the option for 'Include @Library changes in job recent changes' in the section 'Global Pipeline Libraries' under Manage Jenkins -> Configure?  

          Richard added a comment -

          No, I switched to Legacy SCM and unchecked the "Include @Library..." option.

          I have rebuilt all the projects but it still does not work and is triggered every time.

          SCM is Git(lab)

          Richard added a comment - No, I switched to Legacy SCM and unchecked the "Include @Library..." option. I have rebuilt all the projects but it still does not work and is triggered every time. SCM is Git(lab)

          Richard added a comment -

          Richard added a comment - Found the issue https://issues.jenkins.io/browse/JENKINS-71127

          Francesco Pretto added a comment - - edited

          I'm also affected. I have all of my pipelines loading a shared library with:

          @Library('MyJenkinsSharedLibrary@master') _

          This is convenient and I do it under my responsibility: in my experience breaking the build is not as serious as introducing a code regressions and there are remote chances that changes in the shared library will introduce code regressions. But in this way a change in the shared library may trigger a massive recompilation of all projects: this is bad and I also request an option to disable the trigger from changes in the shared library, but still remaining able to track updates to it.

           

          Francesco Pretto added a comment - - edited I'm also affected. I have all of my pipelines loading a shared library with: @Library( 'MyJenkinsSharedLibrary@master' ) _ This is convenient and I do it under my responsibility: in my experience breaking the build is not as serious as introducing a code regressions and there are remote chances that changes in the shared library will introduce code regressions. But in this way a change in the shared library may trigger a massive recompilation of all projects: this is bad and I also request an option to disable the trigger from changes in the shared library, but still remaining able to track updates to it.  

            Unassigned Unassigned
            rtyler R. Tyler Croy
            Votes:
            91 Vote for this issue
            Watchers:
            98 Start watching this issue

              Created:
              Updated: