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

Multibranch pipeline does not handle correctly webhook of kind tag created

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Major Major
    • None
    • Jenkins ver. 2.107.2
      bitbucket-branch-source-plugin 2.2.11
    • 2.2.13

      When I create a tag on Bitbucket Cloud the webhook notify Jenkins for a new tag. But the jenkins plugin does not handle it has a SCM event of kind tag but as branch created event.

       

      The PushHookProcessor should be changed (line 165) to check of which kind of event is the notification.

      if (change.isClosed()) {
      	result.put(new BranchSCMHead(change.getOld().getName(), type), null);
      } else {
      	// created is true
      	Reference newChange = change.getNew();
      	SCMHead head = null;
      	if ("tag".equals(newChange.getType())) {
      		head = new BitbucketTagSCMHead(newChange.getName(), newChange.getDate().getTime(), type);
      	} else {
      		head = new BranchSCMHead(newChange.getName(), type);
      	}
      ...
      }
      

      It is also needed add date to the com.cloudbees.jenkins.plugins.bitbucket.api.BitbucketPushEvent.Reference.

      I also suggest to configure the ObjectMapper in payload parser (JsonParser) to use the ISO8601DateFormat that comes with jackson instead the custom.
      Use a specific deserialiser for BitbucketCloudRepository.updatedOn where BB sends an invalid ISO8601 date format (6 decimal for milliseconds field instead 3 that cause date parse error)

          [JENKINS-51063] Multibranch pipeline does not handle correctly webhook of kind tag created

          Arnaud Deprez added a comment - - edited

          Hi nfalco,

          I didn't see you were working on this issue too ^^.

          FYI, I fixed the issue as you suggested here https://github.com/arnaud-deprez/bitbucket-branch-source-plugin/blob/JENKINS-51063/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/PushHookProcessor.java#L165-L168.

          I tested it and it works, thanks!

          It however does not use yet:

          newChange.getDate().getTime()
          

          because it does not exist in the bitbucket post webhook plugin (bitbucket server) as far as I see.

          Should I submit it as is in a PR or do you prefer to have the clean fix with this date read from the hook ?

          Arnaud Deprez added a comment - - edited Hi nfalco , I didn't see you were working on this issue too ^^. FYI, I fixed the issue as you suggested here https://github.com/arnaud-deprez/bitbucket-branch-source-plugin/blob/JENKINS-51063/src/main/java/com/cloudbees/jenkins/plugins/bitbucket/hooks/PushHookProcessor.java#L165-L168 . I tested it and it works, thanks! It however does not use yet: newChange.getDate().getTime() because it does not exist in the bitbucket post webhook plugin (bitbucket server) as far as I see. Should I submit it as is in a PR or do you prefer to have the clean fix with this date read from the hook ?

          Arjan Schaaf added a comment -

          Hi all,

          Running into the same issue, is there work being done to create a pull request to fix this? This is currently making the combination with webhooks from a Bitbucket server in combination with Tags cumbersome.

          Arjan Schaaf added a comment - Hi all, Running into the same issue, is there work being done to create a pull request to fix this? This is currently making the combination with webhooks from a Bitbucket server in combination with Tags cumbersome.

          Ryan Taylor added a comment - - edited

          We are running into this issue as well.

          We are using

          • Jenkins v2.141 (previously v2.75)
          • Bitbucket Server v5.7.0
          • Bitbucket Branch Source Plugin v2.2.12
          • Webhook to Jenkins for Bitbucket Server Plugin v4.4.2

          Originally I thought this may have been an issue with the Webhook to Jenkins for Bitbucket Server plugin and submitted a support request. They directed me to JENKINS-47254 which lead me to this issue.

          This bug makes it pretty difficult to work with tags in Jenkins + Bitbucket Server. I see from the comments there is a possible fix. Any ETA for when that may be released?

          Ryan Taylor added a comment - - edited We are running into this issue as well. We are using Jenkins v2.141 (previously v2.75) Bitbucket Server v5.7.0 Bitbucket Branch Source Plugin v2.2.12 Webhook to Jenkins for Bitbucket Server Plugin v4.4.2 Originally I thought this may have been an issue with the Webhook to Jenkins for Bitbucket Server plugin and submitted a support request. They directed me to JENKINS-47254 which lead me to this issue. This bug makes it pretty difficult to work with tags in Jenkins + Bitbucket Server. I see from the comments there is a possible fix. Any ETA for when that may be released?

          pixman20 added a comment -

          arnaudeprez

           

          Thanks for the branch.  It works and creates the new tag.
          However, the tag build does not start automatically, even if "branches to build" is set to ".*"
          Any idea how to fix this?

          pixman20 added a comment - arnaudeprez   Thanks for the branch.  It works and creates the new tag. However, the tag build does not start automatically, even if "branches to build" is set to ".*" Any idea how to fix this?

          Nikolas Falco added a comment -

          The branch is intended to trigger a new build for discovered branch job. If you mean that you have "Discover Tags" and the web-hook does not trigger a build it is possible since the Tag job was merged after this issue and PR.

          Nikolas Falco added a comment - The branch is intended to trigger a new build for discovered branch job. If you mean that you have "Discover Tags" and the web-hook does not trigger a build it is possible since the Tag job was merged after this issue and PR.

          Barathwaja S added a comment -

          Is there an ETA? when this updated version of the plugin will be released ? nfalco

          Barathwaja S added a comment - Is there an ETA? when this updated version of the plugin will be released ? nfalco

            nfalco Nikolas Falco
            nfalco Nikolas Falco
            Votes:
            9 Vote for this issue
            Watchers:
            15 Start watching this issue

              Created:
              Updated:
              Resolved: