Skip to content

Commit

Permalink
update TriggerPipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
veziak committed Mar 23, 2023
1 parent 4aedc57 commit 3f920fc
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions pipelines.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package bitbucket
import (
"encoding/json"
"fmt"
"io"
"io/ioutil"
"net/url"
)
Expand Down Expand Up @@ -129,7 +128,7 @@ type BitbucketTrigerPipelineRequestBody struct {
} `json:"target"`
}

func (p *Pipelines) TriggerPipeline(po *PipelinesOptions, body *BitbucketTrigerPipelineRequestBody) (string, error) {
func (p *Pipelines) TriggerPipeline(po *PipelinesOptions, body *BitbucketTrigerPipelineRequestBody) (interface{}, error) {
urlStr := p.c.requestUrl("/repositories/%s/%s/pipelines/", po.Owner, po.RepoSlug)

b, err := json.Marshal(body)
Expand All @@ -138,17 +137,10 @@ func (p *Pipelines) TriggerPipeline(po *PipelinesOptions, body *BitbucketTrigerP
}
data := string(b)

p.c.execute("POST", urlStr, data)
responseBody, err := p.c.executeRaw("GET", urlStr, "")
responseBody, err := p.c.execute("POST", urlStr, data)
if err != nil {
return "failed to trigger bitbucket pipeline", err
}
defer responseBody.Close()

rawBody, err := io.ReadAll(responseBody)
if err != nil {
return "", err
}

return string(rawBody), nil
return responseBody, nil
}

0 comments on commit 3f920fc

Please sign in to comment.