|
1 | 1 | package org.gitlab4j.api; |
2 | 2 |
|
3 | 3 | import java.util.List; |
| 4 | +import java.util.Map; |
4 | 5 | import java.util.Optional; |
5 | 6 | import java.util.stream.Stream; |
6 | 7 |
|
@@ -224,7 +225,25 @@ public Pipeline getPipeline(Object projectIdOrPath, int pipelineId) throws GitLa |
224 | 225 | * @throws GitLabApiException if any exception occurs during execution |
225 | 226 | */ |
226 | 227 | public Pipeline createPipeline(Object projectIdOrPath, String ref) throws GitLabApiException { |
227 | | - GitLabApiForm formData = new GitLabApiForm().withParam("ref", ref); |
| 228 | + return (createPipeline(projectIdOrPath, ref, null)); |
| 229 | + } |
| 230 | + |
| 231 | + /** |
| 232 | + * Create a pipelines in a project. |
| 233 | + * |
| 234 | + * <pre><code>GitLab Endpoint: POST /projects/:id/pipeline</code></pre> |
| 235 | + * |
| 236 | + * @param projectIdOrPath the project in the form of an Integer(ID), String(path), or Project instance |
| 237 | + * @param ref reference to commit |
| 238 | + * @param variables a Map containing the variables available in the pipeline |
| 239 | + * @return a Pipeline instance with the newly created pipeline info |
| 240 | + * @throws GitLabApiException if any exception occurs during execution |
| 241 | + */ |
| 242 | + public Pipeline createPipeline(Object projectIdOrPath, String ref, Map<String, String> variables) throws GitLabApiException { |
| 243 | + |
| 244 | + GitLabApiForm formData = new GitLabApiForm() |
| 245 | + .withParam("ref", ref, true) |
| 246 | + .withParam("variables", variables, false); |
228 | 247 | Response response = post(Response.Status.CREATED, formData.asMap(), "projects", getProjectIdOrPath(projectIdOrPath), "pipeline"); |
229 | 248 | return (response.readEntity(Pipeline.class)); |
230 | 249 | } |
|
0 commit comments