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

Jenkins job getting triggered for every commit made in the repo instead for commits to branch(master)

    XMLWordPrintable

Details

    Description

      Steps to replicate:

      1. Did setup - installing plugin, giving bitbucket instance details with a token in Jenkins --> Manage Jenkins --> Configure System --> Bitbucket Server integration
      2. Created a multi-configuration job and linked with bitbucket repo of master branch to get the code
      3. Create branch(Ex: dev_branch) from a master in the repo and commit any change to the dev_branch

      Actual:

      Job is getting triggered by taking master branch code

      Expected:

      The job should trigger only if there is any new commit to master. However, the job is running for commit made due to dev_branch.
      Running a job with master code even though there are no new changes is not worth it.

      If I select dev_branch in the Job then it should poll for new commits to that branch and trigger.

      Attachments

        Issue Links

          Activity

            msh Marc-Niclas added a comment -

            We have the same problem and it is easy to reproduce as described above.

            I have checked the plugin's source code and found the following lines of code that only check if either the project key and repository slug or the set clone URLs are equal to the ones from the Bitbucket Server webhook. Some kind of check which Git refs have been changed should help here.

            Additionally I want to mention that this does not seem like an issue with a minor priority as for multiple Jenkins Jobs for multiple branches, one commit on one of these branches results to an unnecessary workload on our Jenkins agents.

            msh Marc-Niclas added a comment - We have the same problem and it is easy to reproduce as described above. I have checked the plugin's source code and found the following lines of code that only check if either the project key and repository slug or the set clone URLs are equal to the ones from the Bitbucket Server webhook. Some kind of check which Git refs have been changed should help here. Additionally I want to mention that this does not seem like an issue with a minor priority as for multiple Jenkins Jobs for multiple branches, one commit on one of these branches results to an unnecessary workload on our Jenkins agents.
            ysun_atl Yingran added a comment -

            Hi karthikeya_raja thanks for submitting the report. Unfortunately I was not able to reproduce the issue above. 

            Would you be able to provide some more information about:

            • the version of the `atlassian-bitbucket-server-integration-plugin` you are using
            • the set-up of your multi-config job 
            • the version of the jenkins git plugin

            msh you are correct that the plugin only checks for project key and repo slug. The git ref checking is done by the git jenkins plugin - any refs that don't match what is configured should be filtered out. 

            ysun_atl Yingran added a comment - Hi karthikeya_raja  thanks for submitting the report. Unfortunately I was not able to reproduce the issue above.  Would you be able to provide some more information about: the version of the `atlassian-bitbucket-server-integration-plugin` you are using the set-up of your multi-config job  the version of the jenkins git plugin msh  you are correct that the plugin only checks for project key and repo slug. The git ref checking is done by the git jenkins plugin - any refs that don't match what is configured should be filtered out. 

            hi karthikeya_raja, we are closing this as Cannot Reproduce. Please reopen it if it happens again.

            atlassian_bbs Atlassian Bitbucket Server added a comment - hi karthikeya_raja , we are closing this as Cannot Reproduce. Please reopen it if it happens again.

            People

              Unassigned Unassigned
              karthikeya_raja Karthikeya Raja
              Votes:
              3 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: