|
| 1 | +<?php namespace Gitlab\Api; |
| 2 | + |
| 3 | +class Jobs extends AbstractApi |
| 4 | +{ |
| 5 | + const SCOPE_CREATED = 'created'; |
| 6 | + const SCOPE_PENDING = 'pending'; |
| 7 | + const SCOPE_RUNNING = 'running'; |
| 8 | + const SCOPE_FAILED = 'failed'; |
| 9 | + const SCOPE_SUCCESS = 'success'; |
| 10 | + const SCOPE_CANCELED = 'canceled'; |
| 11 | + const SCOPE_SKIPPED = 'skipped'; |
| 12 | + const SCOPE_MANUAL = 'manual'; |
| 13 | + |
| 14 | + /** |
| 15 | + * @param int|string $project_id |
| 16 | + * @param array $scope |
| 17 | + * @return mixed |
| 18 | + */ |
| 19 | + public function jobs($project_id, array $scope = []) |
| 20 | + { |
| 21 | + return $this->get("projects/".$this->encodePath($project_id)."/jobs", array( |
| 22 | + 'scope' => $scope |
| 23 | + )); |
| 24 | + } |
| 25 | + |
| 26 | + /** |
| 27 | + * @param int|string $project_id |
| 28 | + * @param int $pipeline_id |
| 29 | + * @param array $scope |
| 30 | + * @return mixed |
| 31 | + */ |
| 32 | + public function pipelineJobs($project_id, $pipeline_id, array $scope = []) |
| 33 | + { |
| 34 | + return $this->get("projects/".$this->encodePath($project_id)."/pipelines/".$this->encodePath($pipeline_id)."/jobs", array( |
| 35 | + 'scope' => $scope |
| 36 | + )); |
| 37 | + } |
| 38 | + |
| 39 | + /** |
| 40 | + * @param int|string $project_id |
| 41 | + * @param int $job_id |
| 42 | + * @return mixed |
| 43 | + */ |
| 44 | + public function show($project_id, $job_id) |
| 45 | + { |
| 46 | + return $this->get("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)); |
| 47 | + } |
| 48 | + |
| 49 | + /** |
| 50 | + * @param int|string $project_id |
| 51 | + * @param int $job_id |
| 52 | + * @return string |
| 53 | + */ |
| 54 | + public function artifacts($project_id, $job_id) |
| 55 | + { |
| 56 | + return $this->get("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/artifacts"); |
| 57 | + } |
| 58 | + |
| 59 | + /** |
| 60 | + * @param int|string $project_id |
| 61 | + * @param string $ref_name |
| 62 | + * @param string $job_name |
| 63 | + * @return string |
| 64 | + */ |
| 65 | + public function artifactsByRefName($project_id, $ref_name, $job_name) |
| 66 | + { |
| 67 | + return $this->get("projects/".$this->encodePath($project_id)."/jobs/artifacts/".$this->encodePath($ref_name)."/download", array( |
| 68 | + 'job' => $job_name |
| 69 | + )); |
| 70 | + } |
| 71 | + |
| 72 | + /** |
| 73 | + * @param int|string $project_id |
| 74 | + * @param int $job_id |
| 75 | + * @return string |
| 76 | + */ |
| 77 | + public function trace($project_id, $job_id) |
| 78 | + { |
| 79 | + return $this->get("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/trace"); |
| 80 | + } |
| 81 | + |
| 82 | + /** |
| 83 | + * @param int|string $project_id |
| 84 | + * @param int $job_id |
| 85 | + * @return mixed |
| 86 | + */ |
| 87 | + public function cancel($project_id, $job_id) |
| 88 | + { |
| 89 | + return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/cancel"); |
| 90 | + } |
| 91 | + |
| 92 | + /** |
| 93 | + * @param int|string $project_id |
| 94 | + * @param int $job_id |
| 95 | + * @return mixed |
| 96 | + */ |
| 97 | + public function retry($project_id, $job_id) |
| 98 | + { |
| 99 | + return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/retry"); |
| 100 | + } |
| 101 | + |
| 102 | + /** |
| 103 | + * @param int|string $project_id |
| 104 | + * @param int $job_id |
| 105 | + * @return mixed |
| 106 | + */ |
| 107 | + public function erase($project_id, $job_id) |
| 108 | + { |
| 109 | + return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/erase"); |
| 110 | + } |
| 111 | + |
| 112 | + /** |
| 113 | + * @param int|string $project_id |
| 114 | + * @param int $job_id |
| 115 | + * @return mixed |
| 116 | + */ |
| 117 | + public function keepArtifacts($project_id, $job_id) |
| 118 | + { |
| 119 | + return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/artifacts/keep"); |
| 120 | + } |
| 121 | + |
| 122 | + /** |
| 123 | + * @param int|string $project_id |
| 124 | + * @param int $job_id |
| 125 | + * @return mixed |
| 126 | + */ |
| 127 | + public function play($project_id, $job_id) |
| 128 | + { |
| 129 | + return $this->post("projects/".$this->encodePath($project_id)."/jobs/".$this->encodePath($job_id)."/play"); |
| 130 | + } |
| 131 | +} |
0 commit comments