I have Jenkins Pipeline job define in my git repo as.

// File: deployment/jenkinsfiles/staging/Merge

@Library("my_shared_lib") _

import com.company.myteam.Constants

pipeline {
    agent { label "common" }

    triggers {
        pollSCM("H/2 * * * *")

    options {
        buildDiscarder(logRotator(numToKeepStr: "50", artifactNumToKeepStr: "50"))

    stages {
        stage ("Staging Merge") {
            steps {
                script {
                    def config = new Constants().repoconfig
                    ansiColor("xterm") {
    post {
        always {

Then I created jenkins job configuration as below.

Jenkins Job Config

Now, When I check the Git Polling Log its polling shared-library too.

Started on Feb 25, 2020 5:33:07 PM
Using strategy: Default
[poll] Last Built Revision: Revision 681f996e689bdeb9cfca2b167002b8ccd99590cb (origin/staging)
using credential github_username_with_token
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Github Service Account Username with token
 > git ls-remote -h https://[email protected]/myteam/myrepo # timeout=10
Found 6 remote heads on https://[email protected]/myteam/myrepo
[poll] Latest remote head revision on refs/heads/staging is: 681f996e689bdeb9cfca2b167002b8ccd99590cb - already built by 53
Using strategy: Default
[poll] Last Built Revision: Revision e80628ec7c9dbc59decbc81a3b884dcaa963a8dc (refs/remotes/origin/master)
using credential github_username_with_token
 > git rev-parse --is-inside-work-tree # timeout=10
Fetching changes from the remote Git repositories
 > git config remote.origin.url https://[email protected]/myteam/jenkins-shared-libraries.git # timeout=10
Fetching upstream changes from https://[email protected]/myteam/jenkins-shared-libraries.git
 > git --version # timeout=10
using GIT_ASKPASS to set credentials Github Service Account Username with token
 > git fetch --tags --progress https://[email protected]/myteam/jenkins-shared-libraries.git +refs/heads/*:refs/remotes/origin/* # timeout=10
Polling for changes in
 > git rev-parse refs/remotes/origin/master^{commit} # timeout=10
 > git rev-parse refs/remotes/origin/origin/master^{commit} # timeout=10
 > git log --full-history --no-abbrev --format=raw -M -m --raw e80628ec7c9dbc59decbc81a3b884dcaa963a8dc..869b3a16e07d21a88d557f1857376bfed7717a6e # timeout=10

Whenever I change code in jenkins-shared-library, its start build for the job.

I tried workaround given in https://issues.jenkins.io/browse/JENKINS-39615?focusedCommentId=280729&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-280729, but no luck.

I changed my pollSCM to githubPush, but this also trigger when I change in shared-library.

I tried solution given in https://issues.jenkins-ci.org/browse/JENKINS-41497 as Ignore on push notifications for githubPush() but still its triggering job.

Before moving to pipeline, I had freestyle project. Where there is section Source Code Management, where we can define the branch, and githubPush() was listening on that branch only.

Source Code Management

When we select project type as pipeline there is no Source code management section. May be due to that, its listening for all push events.

By push or poll, I want to restrict my jenkins job to trigger only when there is changes on myrepo.git only.

  • Is there a reason you’re not using Webhooks to trigger the Jenkins Build? Commented Mar 10, 2020 at 16:01
  • I tried webhook too, but it send event when I update my shared library too
    – Nilesh
    Commented Mar 12, 2020 at 1:16
  • That is weird, The webhook should only trigger for the Repo that it was configured for. Commented Mar 13, 2020 at 12:02
  • yes, but that is happening if you have "Source Code Management" section, if you create pipeline, this section is not there. Did you tried on pipeline type of project ?
    – Nilesh
    Commented Mar 13, 2020 at 12:59
  • I'm using Webhooks in combination with Multibranch Pipelines. I've configured my git repo to trigger a webhook on every push to run just this project. Polling should then only happen on a push to the project repo. Commented Mar 13, 2020 at 16:34

2 Answers 2


This issue can be solved by using legacy SCM option. Go to Jenkins -> Manage Jenkins -> Configure System and select "Legacy SCM" option for share libs. this will resolve the issue completely, It worked for us.

enter image description here

  • I've tried the options from Ievgen's answer first, but this is the only solution that worked for me.
    – not2savvy
    Commented Oct 7, 2022 at 13:06

Do I understand correctly that you don't want changes in the shared library to trigger builds for your project/pipeline?

If so, you can do it per-pipeline by modifying the @Library("my_shared_lib") _ statement to include changelog=false parameter, like so @Library("my_shared_lib", changelog=false) _.

You can also do that globally, for a specific library - uncheck the Include @Library changes in job recent changes checkbox (in global Jenkins configuration).

  • I tried that option it was not working for me.
    – nilesh1212
    Commented Jul 27, 2021 at 13:48
  • Although this seems to be the correct solution as described in the docs, it didn't work for me either.
    – not2savvy
    Commented Oct 7, 2022 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.