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

Pipeline script from SCM triggers builds on sub pipeline change

      We are using "pipeline script from SCM" feature in all our services, and they load themselves a generic pipeline located in another Git repo, using following syntax :

      // This pipeline is in all our services
      node {
          // Some treatment ...
      
          // Load the generic pipeline
          git 'http://our-git-url/git/jenkins-pipelines.git'
          load 'generic-pipeline.groovy'
      }()
      

      Now our Jenkins jobs get triggered whenever a change to our service is commited, which is what we want.
      Problem is that the same jenkins job also gets triggered whenever a change is made to the loaded pipeline "generic-pipeline.grovy", when there is supposedly no reason to trigger on such an event.

        1. Jenkins_Pipeline.png
          Jenkins_Pipeline.png
          6 kB
        2. jenkns-plugins.txt
          7 kB
        3. poll.txt
          4 kB

          [JENKINS-35026] Pipeline script from SCM triggers builds on sub pipeline change

          Olivier Revial added a comment - - edited

          Also tried with "poll: false"

          git poll:false, url:'http://our-git-url/git/jenkins-pipelines.git'
          

          ... but without any success.

          Anyone ever encountered this issue ?

          Olivier Revial added a comment - - edited Also tried with "poll: false" git poll: false , url: 'http: //our-git-url/git/jenkins-pipelines.git' ... but without any success. Anyone ever encountered this issue ?

          Oleg Nenashev added a comment -

          For me it seems to be valid behavior for default git plugin behavior.
          A solution would be to configure file filters like other SCM plugins do (e.g. Perforce plugin)

          Oleg Nenashev added a comment - For me it seems to be valid behavior for default git plugin behavior. A solution would be to configure file filters like other SCM plugins do (e.g. Perforce plugin)

          Johnny Willemsen added a comment - - edited

          I see something similar in our setup, we checkout the pipeline from SCM (for example http://our-git-url/git/jenkins-pipelines.git) but exclude .* from the polling because we dont' want all our builds to retrigger at the moment something in that git repository changs. In the pipeline script we use a stage as below, but at the moment the jenkins job is triggered through a timed SCM pull it does rebuild at the moment jenkins-pipelines.git has a change, even that we have said poll to false

          stage('Buildtools checkout') {
          dir ('buildtools')

          { git changelog: false, poll: false, url: 'http://our-git-url/git/jenkins-pipelines.git' }

          dir ('jenkins-jobs')

          { git changelog: false, poll: false, url: 'http://our-git-url/git/another-repo.git' }

          }

          Johnny Willemsen added a comment - - edited I see something similar in our setup, we checkout the pipeline from SCM (for example http://our-git-url/git/jenkins-pipelines.git ) but exclude .* from the polling because we dont' want all our builds to retrigger at the moment something in that git repository changs. In the pipeline script we use a stage as below, but at the moment the jenkins job is triggered through a timed SCM pull it does rebuild at the moment jenkins-pipelines.git has a change, even that we have said poll to false stage('Buildtools checkout') { dir ('buildtools') { git changelog: false, poll: false, url: 'http://our-git-url/git/jenkins-pipelines.git' } dir ('jenkins-jobs') { git changelog: false, poll: false, url: 'http://our-git-url/git/another-repo.git' } }

          Johnny Willemsen added a comment - - edited

          I am attaching a text file with

          • jenkins job that pulls the pipeline script from scm, job is triggered on a schedule but the repository we get the script from isn't pulled
          • the contents of the script, have to us two repositories to get the same, the jenkins-jobs git repo is the same as we get the script from
          • the result of a poll, we had a change in jenkins-jobs, but that shouldn't trigger a build

          Johnny Willemsen added a comment - - edited I am attaching a text file with jenkins job that pulls the pipeline script from scm, job is triggered on a schedule but the repository we get the script from isn't pulled the contents of the script, have to us two repositories to get the same, the jenkins-jobs git repo is the same as we get the script from the result of a poll, we had a change in jenkins-jobs, but that shouldn't trigger a build

          I have basically the same issue.
          I use 1 SCM for all groovy files. Whenever I change just a single file in there, all Jobs which load any groovy from that SCM
          will be triggered.

          I set my jobs as pipelineTriggers and it does not only get triggered when the Service SCM changes, but also when any groovy script in my Pipeline SCM changes (not neccessarily for this job)

          Andre Voigtmann added a comment - I have basically the same issue. I use 1 SCM for all groovy files. Whenever I change just a single file in there, all Jobs which load any groovy from that SCM will be triggered. I set my jobs as pipelineTriggers and it does not only get triggered when the Service SCM changes, but also when any groovy script in my Pipeline SCM changes (not neccessarily for this job)

          We faced the same issue and I found a workaround:
          -In the scm config of the pipeline, include 2 additional behaviours:
          a) "Force polling using workspace"
          b) "Polling ignores commits in certain paths"* --> add to "excluded regions" a regexp for your groovy files. eg. pipelines/.*\.groovy

          That way, the if the polling detects changes in your groovy file won't fire the build

          • You can use other strategies like committer name or message.

          I hope that helps!

          Manuel Fidalgo added a comment - We faced the same issue and I found a workaround: -In the scm config of the pipeline, include 2 additional behaviours: a) "Force polling using workspace" b) "Polling ignores commits in certain paths"* --> add to "excluded regions" a regexp for your groovy files. eg. pipelines/.*\.groovy That way, the if the polling detects changes in your groovy file won't fire the build You can use other strategies like committer name or message. I hope that helps!

          Joe George added a comment - - edited

          I'm also experiencing this with a global pipeline library. Every time I commit to it all builds which use SCM triggers are built.

          See https://issues.jenkins-ci.org/browse/JENKINS-47756

          Joe George added a comment - - edited I'm also experiencing this with a global pipeline library. Every time I commit to it all builds which use SCM triggers are built. See  https://issues.jenkins-ci.org/browse/JENKINS-47756

          Jerald Sabu added a comment -

          Any update on this issue ?
          I get all 7 builds triggered at the same time even when I commit a change to the pipeline script of other builds where scm polling is not even configured.

          Jerald Sabu added a comment - Any update on this issue ? I get all 7 builds triggered at the same time even when I commit a change to the pipeline script of other builds where scm polling is not even configured.

            Unassigned Unassigned
            pommedouze Olivier Revial
            Votes:
            6 Vote for this issue
            Watchers:
            12 Start watching this issue

              Created:
              Updated: