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

Bitbucket Webhook starts new job on pipeline despite "Branches to build" configuration

      Hi,

      we have a pipeline configured with the following trigger

      and:

       

      And in Bitbucket, webhook looks as follows:

      This basically means we want to have pipeline executed every time something is pushed to "master" branch only.

      However we noticed that the pipeline is also triggered when:

      • any new branch is created
      • or any new push to those other branches is performed

      In both cases the event triggered by Bitbucket is : 

      X-Event-Key: repo:refs_changed

      "changes": [
              {
                  "fromHash": "c3a812f6132fb289616d1dfd2ea5d431fcca2553",
                  "ref": {
                      "displayId": "feature/anothertest",
                      "id": "refs/heads/feature/anothertest",
                      "type": "BRANCH"
                  },
                  "refId": "refs/heads/feature/anothertest",
                  "toHash": "bd191884f531a371688d3c9b3248a8a573f3d74d",
                  "type": "UPDATE"
              }
          ],
      ... 

       

      So it seems "Branches to build" is completely ignored and not taken into consideration when triggering the job.

      Could you please check if it is a bug indeed or it works as designed?

       

      Edit:

      One more thing to add regarding "Branches to build". It also seems that when we use env variables (ie. GIT_BRANCH) they are not evaluated later on.
      In result we can see the following at the very beginning of the job:

      git rev-parse refs/remotes/${GIT_BRANCH}^{commit} # timeout=10 

      and git, of course, fails to get anything.

      Not sure if those two things are related, just sharing so you have a full picture.

          [JENKINS-71903] Bitbucket Webhook starts new job on pipeline despite "Branches to build" configuration

          Piotr Kulasek created issue -
          Piotr Kulasek made changes -
          Description Original: Hi,

          we have a pipeline configured with the following trigger
          !image-2023-08-25-23-46-04-297.png!

          and:

          !image-2023-08-25-23-46-36-771.png!

           

          And in Bitbucket, webhook looks as follows:

          !image-2023-08-25-23-47-27-647.png!

          This basically means we want to have pipeline executed every time something is pushed to "master" branch only.

          However we noticed that the pipeline is also triggered when:
           * any new branch is created
           * or any new push to those other branches is performed

          In both cases the event triggered by Bitbucket is : 

          X-Event-Key: repo:refs_changed
          {code:java}
          "changes": [
                  {
                      "fromHash": "c3a812f6132fb289616d1dfd2ea5d431fcca2553",
                      "ref": {
                          "displayId": "feature/anothertest",
                          "id": "refs/heads/feature/anothertest",
                          "type": "BRANCH"
                      },
                      "refId": "refs/heads/feature/anothertest",
                      "toHash": "bd191884f531a371688d3c9b3248a8a573f3d74d",
                      "type": "UPDATE"
                  }
              ],
          ... {code}
           

          So it seems "Branches to build" is completely ignored and not taken into consideration when triggering the job.

          Could you please check if it is a bug indeed or it works as designed?
          New: Hi,

          we have a pipeline configured with the following trigger
          !image-2023-08-25-23-46-04-297.png!

          and:

          !image-2023-08-25-23-46-36-771.png!

           

          And in Bitbucket, webhook looks as follows:

          !image-2023-08-25-23-47-27-647.png!

          This basically means we want to have pipeline executed every time something is pushed to "master" branch only.

          However we noticed that the pipeline is also triggered when:
           * any new branch is created
           * or any new push to those other branches is performed

          In both cases the event triggered by Bitbucket is : 

          X-Event-Key: repo:refs_changed
          {code:java}
          "changes": [
                  {
                      "fromHash": "c3a812f6132fb289616d1dfd2ea5d431fcca2553",
                      "ref": {
                          "displayId": "feature/anothertest",
                          "id": "refs/heads/feature/anothertest",
                          "type": "BRANCH"
                      },
                      "refId": "refs/heads/feature/anothertest",
                      "toHash": "bd191884f531a371688d3c9b3248a8a573f3d74d",
                      "type": "UPDATE"
                  }
              ],
          ... {code}
           

          So it seems "Branches to build" is completely ignored and not taken into consideration when triggering the job.

          Could you please check if it is a bug indeed or it works as designed?

           

          Edit:

          One more thing to add regarding "Branches to build". It also seems that when we use env variables (ie. GIT_BRANCH) they are not evaluated later on.
          In result we can see the following at the very beginning of the job:
          {code:java}
          git rev-parse refs/remotes/${GIT_BRANCH}^{commit} # timeout=10 {code}
          and git, of course, fails to get anything.

          Not sure if those two things are related, just sharing so you have a full picture.
          Piotr Kulasek made changes -
          Environment Original: Jenkins: 2.401.3
          Bitbucket Server Plugin: 3.6.0
          Bitbucket Server: 7.21
          New: Jenkins: 2.401.3
          Bitbucket Server Integration Plugin: 3.6.0
          Bitbucket Server: 7.21
          Piotr Kulasek made changes -
          Summary Original: Bitbucket Webhook starts new job when new branch is created despite "Branches to build" configuration New: Bitbucket Webhook starts new job on pipeline despite "Branches to build" configuration
          Sunny made changes -
          Labels New: triaged

          Vishal Babu added a comment -

          This issue is impacting us in using it. Can someone look into it?

          Vishal Babu added a comment - This issue is impacting us in using it. Can someone look into it?

            Unassigned Unassigned
            kulasekp Piotr Kulasek
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: