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

Pipeline script from SCM triggers builds on sub pipeline change

    Details

    • Similar Issues:

      Description

      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.

        Attachments

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

          Issue Links

            Activity

            pommedouze Olivier Revial created issue -
            pommedouze Olivier Revial made changes -
            Field Original Value New Value
            Description 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.
            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.
            pommedouze Olivier Revial made changes -
            Description 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.
            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.
            pommedouze Olivier Revial made changes -
            Description 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.
            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 :

            {{
            {quote}// 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'
            }(){quote}
            }}

            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.
            pommedouze Olivier Revial made changes -
            Description 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 :

            {{
            {quote}// 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'
            }(){quote}
            }}

            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.
            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.
            pommedouze Olivier Revial made changes -
            Description 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.
            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 :

            {code:java}

            // 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'
            }()
            {code}


            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.
            pommedouze Olivier Revial made changes -
            Attachment jenkns-plugins.txt [ 32780 ]
            pommedouze Olivier Revial made changes -
            Component/s git-plugin [ 15543 ]
            Hide
            pommedouze 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 ?

            Show
            pommedouze 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 ?
            Hide
            oleg_nenashev 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)

            Show
            oleg_nenashev 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)
            rtyler R. Tyler Croy made changes -
            Workflow JNJira [ 171236 ] JNJira + In-Review [ 184238 ]
            Hide
            jwillemsen 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' }

            }

            Show
            jwillemsen 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' } }
            Hide
            jwillemsen 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
            Show
            jwillemsen 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
            jwillemsen Johnny Willemsen made changes -
            Attachment poll.txt [ 34025 ]
            Hide
            andrev68 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)

            Show
            andrev68 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)
            Hide
            manuelfidalgo 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!

            Show
            manuelfidalgo 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!
            externl Joe George made changes -
            Link This issue relates to JENKINS-47756 [ JENKINS-47756 ]
            Hide
            externl 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

            Show
            externl 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
            Hide
            jeraldsm 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.

            Show
            jeraldsm 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.

              People

              • Assignee:
                Unassigned
                Reporter:
                pommedouze Olivier Revial
              • Votes:
                4 Vote for this issue
                Watchers:
                11 Start watching this issue

                Dates

                • Created:
                  Updated: