-
Notifications
You must be signed in to change notification settings - Fork 563
/
Copy pathbitbucket_pipeline.go
46 lines (41 loc) · 1.12 KB
/
bitbucket_pipeline.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package ci_backends
import (
"encoding/json"
"fmt"
orchestrator_bitbucket "github.com/diggerhq/digger/libs/ci/bitbucket"
"github.com/diggerhq/digger/libs/spec"
)
type BitbucketPipelineCI struct {
Client *orchestrator_bitbucket.BitbucketAPI
RepoOwner string
RepoName string
Branch string
}
func (bbp BitbucketPipelineCI) TriggerWorkflow(spec spec.Spec, runName string, vcsToken string) error {
specBytes, err := json.Marshal(spec)
if err != nil {
return fmt.Errorf("could not serialize spec: %v", err)
}
variables := []interface{}{
map[string]string{
"key": "ENVIRONMENT",
"value": "production",
},
map[string]string{
"key": "DIGGER_RUN_SPEC",
"value": string(specBytes),
},
map[string]string{
"key": "DIGGER_BITBUCKET_ACCESS_TOKEN",
"value": vcsToken,
},
}
_, err = bbp.Client.TriggerPipeline(bbp.Branch, variables)
return err
}
// GetWorkflowUrl fetch workflow url after triggering a job
// since some CI don't return url automatically we split it out to become a
// followup method
func (bbp BitbucketPipelineCI) GetWorkflowUrl(spec spec.Spec) (string, error) {
return "", nil
}