-
-
Notifications
You must be signed in to change notification settings - Fork 456
Adding the Jobs API #196
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding the Jobs API #196
Conversation
Thanks for this PR David! As HTTPlug support has now landed in master. Could you rebase this branch and use HTTPlug instead of Buzz? |
Now returning a StreamInterface instead of a string for artifact files.
5a6159d
to
a1174d7
Compare
Hey Fabien! Woot! HTTPlug in master, this is absolutely great news! I've rebased this PR to include HTTPlug. Let me know if you have any comments! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank your for your contribution. It works really well unless the Pipeline model. I also added a note on the Jobs::jobs
method name.
lib/Gitlab/Api/Jobs.php
Outdated
* @param array $scope | ||
* @return mixed | ||
*/ | ||
public function jobs($project_id, array $scope = []) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The name all
seems to be more used than the plural noun form. Could you change the method name to all
?
lib/Gitlab/Model/Pipeline.php
Outdated
{ | ||
$pipeline = new static($project, $data['id'], $client); | ||
|
||
return $job->hydrate($data); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be $pipeline
.
lib/Gitlab/Model/Project.php
Outdated
* @param array $scopes | ||
* @return Job[] | ||
*/ | ||
public function jobs(array $scopes) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a default value for the $scopes
argument?
Done! Thanks for the thorough code review. |
Thank you! |
Hey guys,
Here is a PR to add support for the Jobs API (https://docs.gitlab.com/ce/api/jobs.html)
I wrote this PR because I needed a way to download artifacts files. This should replace the PR #164 that is based on old APIs methods that are no more documented.
One important point: since php-gitlab-api uses Buzz (until #191 is closed), I used Buzz to fetch the files. Buzz does not have the notion of streams... so the whole artifacts file is loaded into a PHP string. This is ok for relatively small files, but if you have an artifacts file that is a gigabyte large, this will certainly be a problem.
Should php-gitlab-api migrate to http-client (please do!), I highly recommend adding additional methods in the Jobs class like:
artifactsAsStream
that returns a stream instead of a string. This way, we can cope with very large artifacts files too.Note: I've been testing this PR in the washingmachine and it seems to be working.
Do not hesitate if you have any comments.