Skip to content

Commit 231825c

Browse files
committed
Add build to project API
Get a single build of a project
1 parent aefeb94 commit 231825c

File tree

2 files changed

+27
-0
lines changed

2 files changed

+27
-0
lines changed

lib/Gitlab/Api/Projects.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,16 @@ public function builds($project_id, $scope = null)
139139
));
140140
}
141141

142+
/**
143+
* @param $project_id
144+
* @param $build_id
145+
* @return mixed
146+
*/
147+
public function build($project_id, $build_id)
148+
{
149+
return $this->get($this->getProjectPath($project_id, 'builds/'.$this->encodePath($build_id)));
150+
}
151+
142152
/**
143153
* @param int $project_id
144154
* @param string $username_query

test/Gitlab/Tests/Api/ProjectsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,23 @@ public function shouldGetBuildsWithMultipleScopes()
238238
$this->assertEquals($expectedArray, $api->builds(1, array('success', 'failed')));
239239
}
240240

241+
/**
242+
* @test
243+
*/
244+
public function shouldGetBuild()
245+
{
246+
$expectedArray = array('id' => 2);
247+
248+
$api = $this->getApiMock();
249+
$api->expects($this->once())
250+
->method('get')
251+
->with('projects/1/builds/2')
252+
->will($this->returnValue($expectedArray))
253+
;
254+
255+
$this->assertEquals($expectedArray, $api->build(1, 2));
256+
}
257+
241258
/**
242259
* @test
243260
*/

0 commit comments

Comments
 (0)