From 3f920fced8835b31bf7ea4f80cefe21ed15b48af Mon Sep 17 00:00:00 2001 From: alexey Date: Thu, 23 Mar 2023 15:45:04 +0000 Subject: [PATCH] update TriggerPipeline --- pipelines.go | 14 +++----------- 1 file changed, 3 insertions(+), 11 deletions(-) diff --git a/pipelines.go b/pipelines.go index 58f86a8..a043df4 100644 --- a/pipelines.go +++ b/pipelines.go @@ -3,7 +3,6 @@ package bitbucket import ( "encoding/json" "fmt" - "io" "io/ioutil" "net/url" ) @@ -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) @@ -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 }