Skip to content

Commit ba62c92

Browse files
authored
Merge pull request #222 from fbourigault/v4-api-9463
Remove deprecated build related endpoints.
2 parents ea1b976 + d7db5ab commit ba62c92

File tree

6 files changed

+40
-186
lines changed

6 files changed

+40
-186
lines changed

UPGRADE.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,14 @@ Use the `deployKeys`, `deployKey`, `addDeployKey`, `deleteDeployKey`, `removeDep
3737
* The `ORDER_BY` and `SORT` class constants have been removed.
3838
* The `accessible`, `owned` and `search` methods have been removed. Use `all` method instead.
3939
* The `all` method now take a single argument which is an associative array of query string parameters.
40+
* The `trace` method have been removed. Use `Gitlab\Api\Jobs::trace` instead.
41+
* The `builds` method have been removed. Use `Gitlab\Api\Jobs::all` instead.
42+
* The `build` method have been removed. Use `Gitlab\Api\Jobs::show` instead.
4043

4144
## `Gitlab\Api\Repositories` changes
4245

4346
* The `commits` page argument now start from 1 instead of 0.
47+
* The `commitBuilds` method have been removed. Use `Gitlab\Api\Projects::pipelines` instead.
4448

4549
## `Gitlab\Model\Project` changes
4650

lib/Gitlab/Api/Projects.php

Lines changed: 34 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -148,44 +148,45 @@ public function unarchive($project_id){
148148
}
149149

150150
/**
151-
* @param int $project_id
152-
* @param array $scope
153-
* @return mixed
154-
*/
155-
public function builds($project_id, $scope = null)
156-
{
157-
return $this->get($this->getProjectPath($project_id, 'builds'), array(
158-
'scope' => $scope
159-
));
160-
}
161-
162-
/**
163-
* @param int $project_id
164-
* @param int $build_id
151+
* @param int $project_id
152+
* @param array $parameters (
153+
*
154+
* @var string $scope The scope of pipelines, one of: running, pending, finished, branches, tags.
155+
* @var string $status The status of pipelines, one of: running, pending, success, failed, canceled, skipped.
156+
* @var string $ref The ref of pipelines.
157+
* @var bool $yaml_errors Returns pipelines with invalid configurations.
158+
* @var string $name The name of the user who triggered pipelines.
159+
* @var string $username The username of the user who triggered pipelines.
160+
* @var string $order_by Order pipelines by id, status, ref, or user_id (default: id).
161+
* @var string $order Sort pipelines in asc or desc order (default: desc).
162+
* )
165163
* @return mixed
166164
*/
167-
public function build($project_id, $build_id)
165+
public function pipelines($project_id, array $parameters = [])
168166
{
169-
return $this->get($this->getProjectPath($project_id, 'builds/'.$this->encodePath($build_id)));
170-
}
167+
$resolver = $this->createOptionsResolver();
168+
$booleanNormalizer = function ($value) {
169+
return $value ? 'true' : 'false';
170+
};
171171

172-
/**
173-
* @param int $project_id
174-
* @param int $build_id
175-
* @return mixed
176-
*/
177-
public function trace($project_id, $build_id)
178-
{
179-
return $this->get($this->getProjectPath($project_id, 'builds/'.$this->encodePath($build_id).'/trace'));
180-
}
172+
$resolver->setDefined('scope')
173+
->setAllowedValues('scope', ['running', 'pending', 'finished', 'branches', 'tags'])
174+
;
175+
$resolver->setDefined('status')
176+
->setAllowedValues('status', ['running', 'pending', 'success', 'failed', 'canceled', 'skipped'])
177+
;
178+
$resolver->setDefined('ref');
179+
$resolver->setDefined('yaml_errors')
180+
->setAllowedTypes('yaml_errors', 'bool')
181+
->setNormalizer('yaml_errors', $booleanNormalizer)
182+
;
183+
$resolver->setDefined('name');
184+
$resolver->setDefined('username');
185+
$resolver->setDefined('order_by')
186+
->setAllowedValues('order_by', ['id', 'status', 'ref', 'user_id'])
187+
;
181188

182-
/**
183-
* @param int $project_id
184-
* @return mixed
185-
*/
186-
public function pipelines($project_id)
187-
{
188-
return $this->get($this->getProjectPath($project_id, 'pipelines'));
189+
return $this->get($this->getProjectPath($project_id, 'pipelines'), $resolver->resolve($parameters));
189190
}
190191

191192
/**

lib/Gitlab/Api/Repositories.php

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -125,24 +125,6 @@ public function updateRelease( $project_id, $tag_name, $description ) {
125125
) );
126126
}
127127

128-
/**
129-
* @param int $project_id
130-
* @param string $sha
131-
* @param string $scope
132-
* @param int $page
133-
* @param int $per_page
134-
*
135-
* @return mixed
136-
*/
137-
public function commitBuilds($project_id, $sha, $scope = null, $page = 0, $per_page = self::PER_PAGE)
138-
{
139-
return $this->get($this->getProjectPath($project_id, 'repository/commits/'.$this->encodePath($sha).'/builds'), array(
140-
'page' => $page,
141-
'per_page' => $per_page,
142-
'scope' => $scope
143-
));
144-
}
145-
146128
/**
147129
* @param int $project_id
148130
* @param int $page

lib/Gitlab/Model/ProjectHook.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
* @property-read bool $push_events
1212
* @property-read bool $issues_events
1313
* @property-read bool $merge_requests_events
14-
* @property-read bool $build_events
14+
* @property-read bool $job_events
1515
* @property-read bool $tag_push_events
1616
* @property-read string $created_at
1717
* @property-read Project $project
@@ -29,7 +29,7 @@ class ProjectHook extends AbstractModel
2929
'push_events',
3030
'issues_events',
3131
'merge_requests_events',
32-
'build_events',
32+
'job_events',
3333
'tag_push_events',
3434
'created_at'
3535
);

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -207,99 +207,6 @@ public function shouldRemoveProject()
207207
$this->assertEquals($expectedBool, $api->remove(1));
208208
}
209209

210-
/**
211-
* @test
212-
*/
213-
public function shouldGetBuilds()
214-
{
215-
$expectedArray = array(
216-
array('id' => 1, 'status' => 'success'),
217-
array('id' => 2, 'status' => 'failed')
218-
);
219-
220-
$api = $this->getApiMock();
221-
$api->expects($this->once())
222-
->method('get')
223-
->with('projects/1/builds')
224-
->will($this->returnValue($expectedArray))
225-
;
226-
227-
$this->assertEquals($expectedArray, $api->builds(1));
228-
}
229-
230-
/**
231-
* @test
232-
*/
233-
public function shouldGetBuildsWithScope()
234-
{
235-
$expectedArray = array(
236-
array('id' => 1, 'status' => 'success'),
237-
);
238-
239-
$api = $this->getApiMock();
240-
$api->expects($this->once())
241-
->method('get')
242-
->with('projects/1/builds', array('scope' => 'success'))
243-
->will($this->returnValue($expectedArray))
244-
;
245-
246-
$this->assertEquals($expectedArray, $api->builds(1, 'success'));
247-
}
248-
249-
/**
250-
* @test
251-
*/
252-
public function shouldGetBuildsWithMultipleScopes()
253-
{
254-
$expectedArray = array(
255-
array('id' => 1, 'status' => 'success'),
256-
array('id' => 1, 'status' => 'failed'),
257-
);
258-
259-
$api = $this->getApiMock();
260-
$api->expects($this->once())
261-
->method('get')
262-
->with('projects/1/builds', array('scope' => array('success', 'failed')))
263-
->will($this->returnValue($expectedArray))
264-
;
265-
266-
$this->assertEquals($expectedArray, $api->builds(1, array('success', 'failed')));
267-
}
268-
269-
/**
270-
* @test
271-
*/
272-
public function shouldGetBuild()
273-
{
274-
$expectedArray = array('id' => 2);
275-
276-
$api = $this->getApiMock();
277-
$api->expects($this->once())
278-
->method('get')
279-
->with('projects/1/builds/2')
280-
->will($this->returnValue($expectedArray))
281-
;
282-
283-
$this->assertEquals($expectedArray, $api->build(1, 2));
284-
}
285-
286-
/**
287-
* @test
288-
*/
289-
public function shouldGetTrace()
290-
{
291-
$expectedString = 'runner trace of a specific build';
292-
293-
$api = $this->getApiMock();
294-
$api->expects($this->once())
295-
->method('get')
296-
->with('projects/1/builds/2/trace')
297-
->will($this->returnValue($expectedString))
298-
;
299-
300-
$this->assertEquals($expectedString, $api->trace(1, 2));
301-
}
302-
303210
/**
304211
* @test
305212
*/

test/Gitlab/Tests/Api/RepositoriesTest.php

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -235,46 +235,6 @@ public function shouldGetCommits()
235235
$this->assertEquals($expectedArray, $api->commits(1));
236236
}
237237

238-
/**
239-
* @test
240-
*/
241-
public function shouldGetCommitBuilds()
242-
{
243-
$expectedArray = array(
244-
array('id' => 'abcd1234', 'status' => 'failed'),
245-
array('id' => 'efgh5678', 'status' => 'success')
246-
);
247-
248-
$api = $this->getApiMock();
249-
$api->expects($this->once())
250-
->method('get')
251-
->with('projects/1/repository/commits/abcd12345/builds', array('page' => 0, 'per_page' => AbstractApi::PER_PAGE, 'scope' => null))
252-
->will($this->returnValue($expectedArray))
253-
;
254-
255-
$this->assertEquals($expectedArray, $api->commitBuilds(1, 'abcd12345'));
256-
}
257-
258-
/**
259-
* @test
260-
*/
261-
public function shouldGetCommitBuildsWithScope()
262-
{
263-
$expectedArray = array(
264-
array('id' => 'abcd1234', 'status' => 'success'),
265-
);
266-
267-
$api = $this->getApiMock();
268-
$api->expects($this->once())
269-
->method('get')
270-
->with('projects/1/repository/commits/abcd12345/builds', array('page' => 0, 'per_page' => AbstractApi::PER_PAGE, 'scope' => 'success'))
271-
->will($this->returnValue($expectedArray))
272-
;
273-
274-
$this->assertEquals($expectedArray, $api->commitBuilds(1, 'abcd12345', 'success'));
275-
}
276-
277-
278238
/**
279239
* @test
280240
*/

0 commit comments

Comments
 (0)