1010 // IPipelineAPI declers Codefresh pipeline API
1111 IPipelineAPI interface {
1212 List () ([]* Pipeline , error )
13- Run (string ) (string , error )
13+ Run (string , * RunOptions ) (string , error )
1414 }
1515
1616 PipelineMetadata struct {
@@ -62,6 +62,11 @@ type (
6262 pipeline struct {
6363 codefresh Codefresh
6464 }
65+
66+ RunOptions struct {
67+ Branch string
68+ Variables map [string ]string
69+ }
6570)
6671
6772func newPipelineAPI (codefresh Codefresh ) IPipelineAPI {
@@ -79,10 +84,18 @@ func (p *pipeline) List() ([]*Pipeline, error) {
7984 return r .Docs , err
8085}
8186
82- func (p * pipeline ) Run (name string ) (string , error ) {
87+ func (p * pipeline ) Run (name string , options * RunOptions ) (string , error ) {
88+ variables := []string {}
89+ for k , v := range options .Variables {
90+ variables = append (variables , fmt .Sprintf ("%s=%s" , k , v ))
91+ }
8392 resp , err := p .codefresh .requestAPI (& requestOptions {
8493 path : fmt .Sprintf ("/api/pipelines/run/%s" , url .PathEscape (name )),
8594 method : "POST" ,
95+ body : map [string ]interface {}{
96+ "branch" : options .Branch ,
97+ "variables" : variables ,
98+ },
8699 })
87100 if err != nil {
88101 return "" , err
0 commit comments