|
9 | 9 | import java.util.List;
|
10 | 10 | import java.util.Optional;
|
11 | 11 | import java.util.stream.Stream;
|
12 |
| - |
13 | 12 | import javax.ws.rs.core.Form;
|
14 | 13 | import javax.ws.rs.core.GenericType;
|
15 | 14 | import javax.ws.rs.core.MediaType;
|
16 | 15 | import javax.ws.rs.core.Response;
|
17 | 16 | import javax.ws.rs.core.Response.Status;
|
18 |
| - |
19 | 17 | import org.gitlab4j.api.models.ArtifactsFile;
|
20 | 18 | import org.gitlab4j.api.models.Job;
|
| 19 | +import org.gitlab4j.api.models.JobAttributes; |
21 | 20 |
|
22 | 21 | /**
|
23 | 22 | * This class provides an entry point to all the GitLab API job calls.
|
@@ -532,9 +531,35 @@ public Job eraseJob(Object projectIdOrPath, Long jobId) throws GitLabApiExceptio
|
532 | 531 | * @throws GitLabApiException if any exception occurs during execution
|
533 | 532 | */
|
534 | 533 | public Job playJob(Object projectIdOrPath, Long jobId) throws GitLabApiException {
|
| 534 | + return playJob(projectIdOrPath, jobId, null); |
| 535 | + } |
| 536 | + |
| 537 | + /** |
| 538 | + * Play specified job with parameters in a project. |
| 539 | + * |
| 540 | + * <pre> |
| 541 | + * <code>GitLab Endpoint: POST /projects/:id/jobs/:job_id/play</code> |
| 542 | + * </pre> |
| 543 | + * |
| 544 | + * @param projectIdOrPath id, path of the project, or a Project instance holding the project ID |
| 545 | + * or path |
| 546 | + * @param jobId the ID to play job |
| 547 | + * @param jobAttributes attributes for the played job |
| 548 | + * @return job instance which just played |
| 549 | + * @throws GitLabApiException if any exception occurs during execution |
| 550 | + */ |
| 551 | + public Job playJob(Object projectIdOrPath, Long jobId, JobAttributes jobAttributes) |
| 552 | + throws GitLabApiException { |
| 553 | + Response response; |
| 554 | + if (jobAttributes == null) { |
535 | 555 | GitLabApiForm formData = null;
|
536 |
| - Response response = post(Status.CREATED, formData, "projects", getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); |
537 |
| - return (response.readEntity(Job.class)); |
| 556 | + response = post(Status.CREATED, formData, "projects", |
| 557 | + getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); |
| 558 | + } else { |
| 559 | + response = post(Status.CREATED, jobAttributes, "projects", |
| 560 | + getProjectIdOrPath(projectIdOrPath), "jobs", jobId, "play"); |
| 561 | + } |
| 562 | + return (response.readEntity(Job.class)); |
538 | 563 | }
|
539 | 564 |
|
540 | 565 | /**
|
|
0 commit comments