This API is intended to aid in the setup and configuration of
projects, builds and runners on Gitlab CI. Authentication is done by
sending the private-token
of a valid user and the url
of an
authorized Gitlab instance via a query string along with the API
request:
GET http://ci.example.com/api/v1/projects?private_token=QVy1PB7sTxfy4pqfZM1U&url=http://demo.gitlab.com/
If preferred, you may instead send the private-token
as a header in
your request:
curl --header "PRIVATE-TOKEN: QVy1PB7sTxfy4pqfZM1U" "http://ci.example.com/api/v1/projects?url=http://demo.gitlab.com/"
All API requests are serialized using JSON. You don't need to specify
.json
at the end of API URL.
This lists all the requests that can be made via the API.
Lists all projects that the authenticated user has access to.
GET /projects
Returns:
[
{
"id" : 271,
"name" : "gitlabhq",
"timeout" : 1800,
"scripts" : "ls",
"token" : "iPWx6WM4lhHNedGfBpPJNP",
"default_ref" : "master",
"gitlab_url" : "http://demo.gitlabhq.com/gitlab/gitlab-shell",
"always_build" : false,
"polling_interval" : null,
"public" : false,
"ssh_url_to_repo" : "[email protected]:gitlab/gitlab-shell.git",
"gitlab_id" : 3
},
{
"id" : 272,
"name" : "gitlab-ci",
"timeout" : 1800,
"scripts" : "ls",
"token" : "iPWx6WM4lhHNedGfBpPJNP",
"default_ref" : "master",
"gitlab_url" : "http://demo.gitlabhq.com/gitlab/gitlab-shell",
"always_build" : false,
"polling_interval" : null,
"public" : false,
"ssh_url_to_repo" : "[email protected]:gitlab/gitlab-shell.git",
"gitlab_id" : 4
}
]
Lists all projects that the authenticated user owns.
GET /projects/owned
Returns:
[
{
"id" : 272,
"name" : "gitlab-ci",
"timeout" : 1800,
"scripts" : "ls",
"token" : "iPWx6WM4lhHNedGfBpPJNP",
"default_ref" : "master",
"gitlab_url" : "http://demo.gitlabhq.com/gitlab/gitlab-shell",
"always_build" : false,
"polling_interval" : null,
"public" : false,
"ssh_url_to_repo" : "[email protected]:gitlab/gitlab-shell.git",
"gitlab_id" : 4
}
]
Returns information about a single project for which the user is authorized.
GET /projects/:id
Parameters:
id
(required) - The ID of the Gitlab CI project
Creates a Gitlab CI project using Gitlab project details.
POST /projects/:id
Parameters:
name
(required) - The name of the projectgitlab_id
(required) - The ID of the project on the Gitlab instancegitlab_url
(required) - The web url of the project on the Gitlab instancessh_url_to_repo
(required) - The gitlab SSH url to the reposcripts
(optional) - The shell script provided for a runner to run (defaults tols -al
)default_ref
(optional) - The branch to run on (default tomaster
)
Updates a Gitlab CI project using Gitlab project details that the authenticated user has access to.
PUT /projects/:id
Parameters:
name
- The name of the projectgitlab_id
- The ID of the project on the Gitlab instancegitlab_url
- The web url of the project on the Gitlab instancessh_url_to_repo
- The gitlab SSH url to the reposcripts
- The shell script provided for a runner to run (defaults tols -al
)default_ref
- The branch to run on (default tomaster
)
Removes a Gitlab CI project that the authenticated user has access to.
DELETE /projects/:id
Parameters:
id
(required) - The ID of the Gitlab CI project
Links a runner to a project so that it can make builds (only via authorized user).
POST /projects/:id/runners/:runner_id
Parameters:
id
(required) - The ID of the Gitlab CI projectrunner_id
(required) - The ID of the Gitlab CI runner
Removes a runner from a project so that it can not make builds (only via authorized user).
DELETE /projects/:id/runners/:runner_id
Parameters:
id
(required) - The ID of the Gitlab CI projectrunner_id
(required) - The ID of the Gitlab CI runner
Used to get information about all runners registered on the Gitlab CI instance.
GET /runners
Returns:
[
{
"id" : 85,
"token" : "12b68e90394084703135"
},
{
"id" : 86,
"token" : "76bf894e969364709864"
},
]
Used to make Gitlab CI aware of available runners.
POST /runners/register
Parameters:
token
(required) - The unique token of runnerpublic_key
(required) - Deploy key used to get projects
Returns:
{
"id" : 85,
"token" : "12b68e90394084703135"
}
POST /builds/register
Parameters:
token
(required) - The unique token of runner
Returns:
{
"id" : 79,
"commands" : "",
"path" : "",
"ref" : "",
"sha" : "",
"project_id" : 6,
"repo_url" : "[email protected]:gitlab/gitlab-shell.git",
"before_sha" : ""
}
PUT /builds/:id
Parameters:
id
(required) - The ID of a projectstate
(optional) - The state of a buildtrace
(optional) - The trace of a build