Andres Rojano Ruiz
Andres Rojano Ruiz

Reputation: 1039

Get latest success commit on GitLab Continuous Integration

I´m working with my own GitLab and GitLab CI server. I´d like to get the latest success commit.

I just can get my latest build status off a branch from the URL:

      http://mygitlab.ci/projects/3/status?ref=master

I need that in order to deploy the latest success version of my repo, but I really don´t understand CI with own GitLab and there are not a lot of documentation.

UPDATE:

i.e. In the picture you can see the latest 3 commits and their status. I really need to get the latest success commit (763a3077).

enter image description here

Upvotes: 5

Views: 3254

Answers (1)

Andres Rojano Ruiz
Andres Rojano Ruiz

Reputation: 1039

Solved:

Here I have the answer. The URL must be something like this:

  http://my.gitlabci/api/v1/commits?project_token=<my-project-token>&project_id=<my-project-id>

GET /commits

Parameters:

  • project_id (required) - The ID of a project
  • project_token (requires) - Project token
  • page (optional)
  • per_page (optional) - items per request (default is 20)

https://docs.gitlab.com/ee/api/commits.html

Upvotes: 3

Related Questions