Merge pull request #1333 from gtaylor/bitbucket_tag_hook
Adding Bitbucket tag push hook support.
This commit is contained in:
commit
4847e0971a
1 changed files with 13 additions and 4 deletions
|
@ -397,17 +397,26 @@ func (bb *Bitbucket) pushHook(r *http.Request) (*model.Repo, *model.Build, error
|
||||||
// change that has branch information.
|
// change that has branch information.
|
||||||
for _, change := range hook.Push.Changes {
|
for _, change := range hook.Push.Changes {
|
||||||
|
|
||||||
// must have branch and sha information
|
// must have sha information
|
||||||
if change.New.Type != "branch" || change.New.Target.Hash == "" {
|
if change.New.Target.Hash == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// we only support tag and branch pushes for now
|
||||||
|
buildEventType := model.EventPush
|
||||||
|
buildRef := fmt.Sprintf("refs/heads/%s", change.New.Name)
|
||||||
|
if change.New.Type == "tag" || change.New.Type == "annotated_tag" {
|
||||||
|
buildEventType = model.EventTag
|
||||||
|
buildRef = fmt.Sprintf("refs/tags/%s", change.New.Name)
|
||||||
|
} else if change.New.Type != "branch" {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// return the updated repository information and the
|
// return the updated repository information and the
|
||||||
// build information.
|
// build information.
|
||||||
return convertRepo(&hook.Repo), &model.Build{
|
return convertRepo(&hook.Repo), &model.Build{
|
||||||
Event: model.EventPush,
|
Event: buildEventType,
|
||||||
Commit: change.New.Target.Hash,
|
Commit: change.New.Target.Hash,
|
||||||
Ref: fmt.Sprintf("refs/heads/%s", change.New.Name),
|
Ref: buildRef,
|
||||||
Link: change.New.Target.Links.Html.Href,
|
Link: change.New.Target.Links.Html.Href,
|
||||||
Branch: change.New.Name,
|
Branch: change.New.Name,
|
||||||
Message: change.New.Target.Message,
|
Message: change.New.Target.Message,
|
||||||
|
|
Loading…
Reference in a new issue