Skip to content

Commit f7c77db

Browse files
Get pipeline bridge jobs method (#602)
1 parent 25330c1 commit f7c77db

File tree

3 files changed

+44
-0
lines changed

3 files changed

+44
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
88
## [10.2.0] - UPCOMING
99

1010
* Added variable_type to addVariable and updateVariable
11+
* Added get pipeline bridget jobs method
1112

1213
[10.2.0]: https://github.com/GitLabPHP/Client/compare/10.1.1...10.2.0
1314

src/Api/Jobs.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,27 @@ public function pipelineJobs($project_id, int $pipeline_id, array $parameters =
8787
);
8888
}
8989

90+
/**
91+
* @param int|string $project_id
92+
* @param int $pipeline_id
93+
* @param array $parameters {
94+
*
95+
* @var string|string[] $scope The scope of bridge jobs to show, one or array of: created, pending, running, failed,
96+
* success, canceled, skipped, manual; showing all jobs if none provided.
97+
* }
98+
*
99+
* @return mixed
100+
*/
101+
public function pipelineBridges($project_id, int $pipeline_id, array $parameters = [])
102+
{
103+
$resolver = $this->createOptionsResolver();
104+
105+
return $this->get(
106+
$this->getProjectPath($project_id, 'pipelines/').self::encodePath($pipeline_id).'/bridges',
107+
$resolver->resolve($parameters)
108+
);
109+
}
110+
90111
/**
91112
* @param int|string $project_id
92113
* @param int $job_id

tests/Api/JobsTest.php

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,28 @@ public function shouldGetPipelineJobs(): void
5353
$this->assertEquals($expectedArray, $api->pipelineJobs(1, 2, ['scope' => [Jobs::SCOPE_PENDING, Jobs::SCOPE_RUNNING]]));
5454
}
5555

56+
/**
57+
* @test
58+
*/
59+
public function shouldGetPipelineBridges(): void
60+
{
61+
$expectedArray = [
62+
['id' => 1, 'name' => 'A bridge job'],
63+
['id' => 2, 'name' => 'Another bridge job'],
64+
];
65+
66+
$api = $this->getApiMock();
67+
$api->expects($this->once())
68+
->method('get')
69+
->with('projects/1/pipelines/2/bridges', [
70+
'scope' => ['pending', 'running'],
71+
])
72+
->will($this->returnValue($expectedArray))
73+
;
74+
75+
$this->assertEquals($expectedArray, $api->pipelineBridges(1, 2, ['scope' => [Jobs::SCOPE_PENDING, Jobs::SCOPE_RUNNING]]));
76+
}
77+
5678
/**
5779
* @test
5880
*/

0 commit comments

Comments
 (0)