Skip to content

Commit 9841383

Browse files
authored
[11.9] Add support for Jobs::artifactByJobId (#734)
1 parent 83ec71f commit 9841383

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/Api/Jobs.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,18 @@ public function artifactByRefName($project_id, string $ref_name, string $job_nam
169169
])->getBody();
170170
}
171171

172+
/**
173+
* @param int|string $project_id
174+
* @param int $job_id
175+
* @param string $artifact_path
176+
*
177+
* @return StreamInterface
178+
*/
179+
public function artifactByJobId($project_id, $job_id, string $artifact_path)
180+
{
181+
return $this->getAsResponse('projects/'.self::encodePath($project_id).'/jobs/'.self::encodePath($job_id).'/artifacts/'.self::encodePath($artifact_path))->getBody();
182+
}
183+
172184
/**
173185
* @param int|string $project_id
174186
* @param int $job_id

tests/Api/JobsTest.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -119,6 +119,23 @@ public function shouldGetArtifacts(): void
119119
$this->assertEquals('foobar', $api->artifacts(1, 3)->getContents());
120120
}
121121

122+
/**
123+
* @test
124+
*/
125+
public function shouldGetArtifactsByJobId(): void
126+
{
127+
$returnedStream = new Response(200, [], 'foobar');
128+
129+
$api = $this->getApiMock();
130+
$api->expects($this->once())
131+
->method('getAsResponse')
132+
->with('projects/1/jobs/3/artifacts/artifact_path')
133+
->will($this->returnValue($returnedStream))
134+
;
135+
136+
$this->assertEquals('foobar', $api->artifactByJobId(1, 3, 'artifact_path')->getContents());
137+
}
138+
122139
/**
123140
* @test
124141
*/

0 commit comments

Comments
 (0)