Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions docs/docs/20-usage/20-workflow-syntax.md
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,7 @@ when:
#### `path`

:::info
Path conditions are applied only to **push** and **pull_request** events.
It is currently **only available** for GitHub, GitLab and Gitea (version 1.18.0 and newer)
Path conditions are applied only to **push** and **pull_request** events. This feature is currently available for all forges except Bitbucket Cloud.
:::

Execute a step only on a pipeline with certain files being changed:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@
| Event: Release | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
| Event: Deploy¹ | :white_check_mark: | :x: | :x: | :x: | :x: | :x: |
| [Multiple workflows](../../../20-usage/25-workflows.md) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: |
| [when.path filter](../../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :x: |
| [when.path filter](../../../20-usage/20-workflow-syntax.md#path) | :white_check_mark: | :white_check_mark: | :white_check_mark: | :white_check_mark: | :x: | :white_check_mark: |

¹ The deployment event can be triggered for all forges from Woodpecker directly. However, only GitHub can trigger them using webhooks.
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ require (
github.com/mattn/go-sqlite3 v1.14.28
github.com/moby/term v0.5.2
github.com/muesli/termenv v0.16.0
github.com/neticdk/go-bitbucket v1.0.2
github.com/neticdk/go-bitbucket v1.0.3
github.com/oklog/ulid/v2 v2.1.1
github.com/pkg/errors v0.9.1
github.com/prometheus/client_golang v1.22.0
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -440,8 +440,8 @@ github.com/muesli/termenv v0.16.0 h1:S5AlUN9dENB57rsbnkPyfdGuWIlkmzJjbFf0Tf5FWUc
github.com/muesli/termenv v0.16.0/go.mod h1:ZRfOIKPFDYQoDFF4Olj7/QJbW60Ol/kL1pU3VfY/Cnk=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA=
github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ=
github.com/neticdk/go-bitbucket v1.0.2 h1:zNyz/fJ7ANcyfNj3ld1zjEaTG+5iRkQ/R4+FY7Kfe6A=
github.com/neticdk/go-bitbucket v1.0.2/go.mod h1:p1jIRloOKeteK0S5QwyFR2csHyQ7w5AhotXlo+LAs8M=
github.com/neticdk/go-bitbucket v1.0.3 h1:d4uk+WwwxanJZMMyP6DC1dZDnqopPTzzpcijdDkRt9w=
github.com/neticdk/go-bitbucket v1.0.3/go.mod h1:p1jIRloOKeteK0S5QwyFR2csHyQ7w5AhotXlo+LAs8M=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
github.com/nxadm/tail v1.4.8 h1:nPr65rt6Y5JFSKQO7qToXr7pePgD6Gwiw05lkbyAQTE=
github.com/nxadm/tail v1.4.8/go.mod h1:+ncqLTQzXmGhMZNUePPaPqPvBxHAIsmXswZKocGu+AU=
Expand Down
37 changes: 34 additions & 3 deletions server/forge/bitbucketdatacenter/bitbucketdatacenter.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,6 +481,7 @@ func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model

var repo *model.Repo
var pipe *model.Pipeline

switch e := ev.(type) {
case *bb.RepositoryPushEvent:
repo = convertRepo(&e.Repository, nil, "")
Expand All @@ -494,17 +495,23 @@ func (c *client) Hook(ctx context.Context, r *http.Request) (*model.Repo, *model

user, repo, err := c.getUserAndRepo(ctx, repo)
if err != nil {
return nil, nil, err
return nil, nil, fmt.Errorf("failed to get user and repo: %w", err)
}

err = bb.ValidateSignature(r, payload, []byte(repo.Hash))
if err != nil {
return nil, nil, fmt.Errorf("unable to validate signature on incoming webhook payload: %w", err)
}

pipe, err = c.updatePipelineFromCommit(ctx, user, repo, pipe)
switch e := ev.(type) {
case *bb.RepositoryPushEvent:
pipe, err = c.updatePipelineFromCommit(ctx, user, repo, pipe)
case *bb.PullRequestEvent:
pipe, err = c.updatePipelineFromPullRequest(ctx, user, repo, pipe, e.PullRequest.ID)
Comment thread
anbraten marked this conversation as resolved.
}

if err != nil {
return nil, nil, err
return nil, nil, fmt.Errorf("failed to update pipeline: %w", err)
}

if pipe == nil {
Expand Down Expand Up @@ -572,6 +579,30 @@ func (c *client) updatePipelineFromCommit(ctx context.Context, u *model.User, r
return p, nil
}

func (c *client) updatePipelineFromPullRequest(ctx context.Context, u *model.User, r *model.Repo, p *model.Pipeline, pullRequestID uint64) (*model.Pipeline, error) {
bc, err := c.newClient(ctx, u)
if err != nil {
return nil, fmt.Errorf("unable to create bitbucket client: %w", err)
}

opts := &bb.ListOptions{}
for {
changes, resp, err := bc.Projects.ListPullRequestChanges(ctx, r.Owner, r.Name, pullRequestID, opts)
if err != nil {
return nil, fmt.Errorf("unable to list changes in pull request: %w", err)
}
for _, ch := range changes {
p.ChangedFiles = append(p.ChangedFiles, ch.Path.Title)
}
if resp.LastPage {
break
}
opts.Start = resp.NextPageStart
}

return p, nil
}

// Teams fetches all the projects for a given user and converts them into teams.
func (c *client) Teams(ctx context.Context, u *model.User) ([]*model.Team, error) {
opts := &bb.ListOptions{Limit: listLimit}
Expand Down
2 changes: 1 addition & 1 deletion server/forge/bitbucketdatacenter/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ func convertPullRequestEvent(ev *bb.PullRequestEvent, baseURL string) *model.Pip
Commit: ev.PullRequest.Source.Latest,
Branch: ev.PullRequest.Source.DisplayID,
Title: ev.PullRequest.Title,
Message: "",
Message: ev.PullRequest.Title,
Avatar: bitbucketAvatarURL(baseURL, ev.Actor.Slug),
Author: authorLabel(ev.Actor.Name),
Email: ev.Actor.Email,
Expand Down
2 changes: 2 additions & 0 deletions server/forge/bitbucketdatacenter/convert_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,7 @@ func Test_convertPullRequestEvent(t *testing.T) {
Event: model.EventPull,
Refspec: "branch:main",
Title: "my title",
Message: "my title",
}, to)
}

Expand Down Expand Up @@ -278,6 +279,7 @@ func Test_convertPullRequestCloseEvent(t *testing.T) {
Event: model.EventPullClosed,
Refspec: "branch:main",
Title: "my title",
Message: "my title",
}, to)
}

Expand Down