0

Our Bitbucker server is configured to invoke webhooks (received by Jenkins) on push events, which include branch updates, and tags added. The HTTP POST content included in this webhook is a JSON describing the event. The event payloads are described here: https://confluence.atlassian.com/bitbucketserver076/event-payload-1026535078.html

(I'll use "$" to refer to the root of the received JSON)

When I perform a git push origin {my_branch}, the JSON included in the webhook gives values for $.changes[0].fromHash and $.changes[0].toHash that I can correlate to my git log.
E.g., if the received JSON is:

{  
  "eventKey":"repo:refs_changed",
  "date":"2017-09-19T09:45:32+1000",
  "actor":{ ...  },
  "repository":{  ...  },
  "changes":[  
    {  
      "ref":{  
        "id":"refs/heads/master",
        "displayId":"master",
        "type":"BRANCH"
      },
      "refId":"refs/heads/master",
      "fromHash":"ecddabb624f6f5ba43816f5926e580a5f680a932",
      "toHash":"178864a7d521b6f5e720b386b2c2b0ef8563e0dc",
      "type":"UPDATE"
    }
  ]
}

...then I'd be able to see {fromHash} and {toHash} in my git log, e.g.:

$ git log --oneline -n 4
178864a sit
dcbc68d dolor
ecddabb ipsum
b8bf8f0 lorem

But when I push a git tag, e.g.:

$ git tag -a 0.1.0 -m "0.1.0"
$ git push origin 0.1.0

...then {fromHash} is the obviously-invalid 0000..., but {toHash} is a not-obviously-invalid value that I cannot reconcile with anything in my git log. E.g.:

{  
  "eventKey":"repo:refs_changed",
  "date":"2017-09-19T09:47:32+1000",
  "actor":{ ...  },
  "repository":{  ...  },
  "changes":[  
    {  
      "ref":{  
        "id":"refs/tags/0.1.0",
        "displayId":"0.1.0",
        "type":"TAG"
      },
      "refId":"refs/tags/0.1.0",
      "fromHash":"0000000000000000000000000000000000000000",
      "toHash":"b82dd854c413d8e09aaf68c3c286f11ec6780be6",
      "type":"ADD"
    }
  ]
}

The git log output remains unchanged in my shell, so what does the {toHash} value of b82dd85... represent?

StoneThrow
  • 5,314
  • 4
  • 44
  • 86

1 Answers1

0

The toHash represents the SHA of the annotated tag you created with git tag -a ... You can see both the commit id and the SHA of the tag object with git show-ref --tags -d:

In your case it should show something like this

$ git show-ref --tags -d | grep 0.1.0

b82dd854c413d8e09aaf68c3c286f11ec6780be6 refs/tags/0.1.0
178864a7d521b6f5e720b386b2c2b0ef8563e0dc refs/tags/0.1.0^{}
Antoine
  • 1,393
  • 4
  • 20
  • 26
sandra
  • 1
  • 2