Skip to content

Commit 1cc34af

Browse files
author
Vyacheslav Pryimak
authored
Merge pull request #6 from EGT-Ukraine/fix/variables
variables fix
2 parents 1c73647 + cac8727 commit 1cc34af

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ options:
1818
* `--schema` - (optional. default: https) set http or https connection type;
1919
* `--ref` - (optional) branch for the project. (default: master);
2020
* `--urlPrefix` - (optional) if you are use some prefix for your Gitlab (final URL will be looked like: /prefix/api/v4/...);
21-
* `--variables` - (optional) custom variables for the project (format example: `variable1:value,variable2:value`)
21+
* `--variables` - (optional) custom variables for the project
2222

2323
### Run:
2424

2525
```bash
26-
./gtw --privateToken ${PRIVATE_TOKEN} --token ${TOKEN} --host gitlab.egt.com --projectID 123 run
26+
./gtw --privateToken ${PRIVATE_TOKEN} --token ${TOKEN} --host gitlab.egt.com --projectID 123 --variables KEY1:VALUE1 --variables KEY2:VALUE2 run
2727
```

trigger/trigger.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -73,10 +73,10 @@ func (p Trigger) RunPipeline() (*models.CreatePipelineResponse, error) {
7373

7474
vars := p.urlVariables()
7575
if p.token != "" {
76-
vars.Add("token", p.token)
76+
vars.Set("token", p.token)
7777
}
7878
if p.ref != "" {
79-
vars.Add("ref", p.ref)
79+
vars.Set("ref", p.ref)
8080
}
8181

8282
req, err := http.NewRequest(http.MethodPost, u, strings.NewReader(vars.Encode()))
@@ -126,7 +126,7 @@ func (p Trigger) PollForCompletion(pipelineID int64) (*models.PipelineStatusResp
126126
headers := p.defaultHeaders()
127127
headers["PRIVATE-TOKEN"] = []string{p.privateToken}
128128

129-
req, err := http.NewRequest(http.MethodGet, u, strings.NewReader(p.urlVariables().Encode()))
129+
req, err := http.NewRequest(http.MethodGet, u, nil)
130130
if err != nil {
131131
return nil, errors.Wrap(err, "create request failed")
132132
}
@@ -167,7 +167,7 @@ func (p Trigger) PollForCompletion(pipelineID int64) (*models.PipelineStatusResp
167167

168168
func (p Trigger) defaultHeaders() map[string][]string {
169169
return map[string][]string{
170-
"Content-Type": {"multipart/form-data"},
170+
"Content-Type": {"application/x-www-form-urlencoded"},
171171
}
172172
}
173173

@@ -188,7 +188,7 @@ func (p Trigger) urlVariables() url.Values {
188188
for _, variable := range p.variables {
189189
kv := strings.SplitN(variable, ":", 2)
190190
if len(kv) == 2 {
191-
values.Add(fmt.Sprintf("variables[%s]", kv[0]), kv[1])
191+
values.Set(fmt.Sprintf("variables[%s]", kv[0]), kv[1])
192192
}
193193
}
194194

0 commit comments

Comments
 (0)