I think the best way to do it is re-use models we already have and used by internal CI:
Commit
sha
branch/tag name
project id
external_url (point to CI page with commit)
Build
status (success, failed, etc)
commit_id
name (optional)
We can unify this in one api call like:
POST /ci/api/status { sha: "ad321fas", # Commit sha ref: "refs/heads/master" # Branch or tag name name: "spec" # Name of status project_id: 123, # Project external_url: "http://jenkins.example.com/builds/123" status: "success"}
This information will be enough to create Commit and Build objects.
sha: "ad321fas", | in url | in url ref: "refs/heads/master" | not included | not included name: "spec" | context | name project_id: 123, | in url | in url external_url: "URL" | target_url | url status: "success" | state | state
I think we should rename status to state.
I think we should add a description as @ayufan suggested and GitHub and Stash have.
We should exclude ref as a requirement in POST, as it would just make it harder to work with our API.
If we do the two other things @sytses has suggested, this makes it very easy to work with our API for existing services. They'll only have to change the root url and authentication.
Lets try to make it without ref. But we need to make changes on GitLab CI side. Now ref is part of routing and you can have same commit with different builds on different branches.
The :id/repository/commits/:sha/status accepts POST with: # id (required) - The ID of a project # sha (required) - The commit hash # ref (optional) - The ref # state (required) - The state of the status. Can be: pending, running, success, error or failure # target_url (optional) - The target URL to associate with this status # description (optional) - A short description of the status # context (optional) - A string label to differentiate this status from the status of other systems. Default: "default"
What does it mean if you test against that instead of the commit itself?
Ref allows the service to be more specific against which ref it was testing the :sha. We also use :ref tracking in GitLab CI, because in our builds we often have different pipelines for tags and branches, ie. omnibus package.
Can we use :owner/:repo/statuses/:sha as endpoint?
I don't see any objections to have:
projects/:id/statuses/:sha
Where :id can be numeric ID of project or :namespace/:project.