Commit 75123fa9 authored by Z.J. van de Weg's avatar Z.J. van de Weg

Incorporate review, drop old endpoint

The endpoint dropped, get ':id/repository/commits/:sha/jobs', should be
replace by a new endpoint.
parent 19422347
......@@ -70,7 +70,7 @@ GET /projects/:id/services/assembla
## Atlassian Bamboo CI
A continuous integration and job server
A continuous integration and build server
### Create/Edit Atlassian Bamboo CI service
......@@ -85,7 +85,7 @@ PUT /projects/:id/services/bamboo
Parameters:
- `bamboo_url` (**required**) - Bamboo root URL like https://bamboo.example.com
- `job_key` (**required**) - Bamboo job plan key like KEY
- `build_key` (**required**) - Bamboo build plan key like KEY
- `username` (**required**) - A user with API access, if applicable
- `password` (**required**)
......@@ -114,13 +114,13 @@ Continuous integration and deployments
Set Buildkite service for a project.
```
PUT /projects/:id/services/jobkite
PUT /projects/:id/services/buildkite
```
Parameters:
- `token` (**required**) - Buildkite project GitLab token
- `project_url` (**required**) - https://jobkite.com/example/project
- `project_url` (**required**) - https://buildkite.com/example/project
- `enable_ssl_verification` (optional) - Enable SSL verification
### Delete Buildkite service
......@@ -128,7 +128,7 @@ Parameters:
Delete Buildkite service for a project.
```
DELETE /projects/:id/services/jobkite
DELETE /projects/:id/services/buildkite
```
### Get Buildkite service settings
......@@ -136,12 +136,12 @@ DELETE /projects/:id/services/jobkite
Get Buildkite service settings for a project.
```
GET /projects/:id/services/jobkite
GET /projects/:id/services/buildkite
```
## Build-Emails
Get emails for GitLab CI jobs.
Get emails for GitLab CI builds.
### Create/Edit Build-Emails service
......
......@@ -59,6 +59,8 @@ changes are in V4:
- Return 202 with JSON body on async removals on V4 API (DELETE `/projects/:id/repository/merged_branches` and DELETE `/projects/:id`) [!9449](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9449)
- `projects/:id/milestones?iid[]=x&iid[]=y` array filter has been renamed to `iids` [!9096](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9096)
- Return basic info about pipeline in `GET /projects/:id/pipelines` [!8875](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/8875)
- Renamed all `build` references to `job` [!9463](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9463)
- Drop GET '/projects/:id/repository/commits/:sha/jobs' [!9463](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9463)
- Rename Build Triggers to be Pipeline Triggers API [!9713](https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/9713)
- `POST /projects/:id/trigger/builds` to `POST /projects/:id/trigger/pipeline`
- Require description when creating a new trigger `POST /projects/:id/triggers`
......@@ -40,27 +40,6 @@ class Jobs < Grape::API
user_can_download_artifacts: can?(current_user, :read_build, user_project)
end
desc 'Get jobs for a specific commit of a project' do
success Entities::Job
end
params do
requires :sha, type: String, desc: 'The SHA id of a commit'
use :optional_scope
use :pagination
end
get ':id/repository/commits/:sha/jobs' do
authorize_read_builds!
return not_found! unless user_project.commit(params[:sha])
pipelines = user_project.pipelines.where(sha: params[:sha])
builds = user_project.builds.where(pipeline: pipelines).order('id DESC')
builds = filter_builds(builds, params[:scope])
present paginate(builds), with: Entities::Job,
user_can_download_artifacts: can?(current_user, :read_build, user_project)
end
desc 'Get a specific job of a project' do
success Entities::Job
end
......
......@@ -11,7 +11,7 @@ class Deployments < Grape::API
resource :projects do
desc 'Get all deployments of the project' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities::Deployment
success ::API::V3::Deployments
end
params do
use :pagination
......@@ -19,12 +19,12 @@ class Deployments < Grape::API
get ':id/deployments' do
authorize! :read_deployment, user_project
present paginate(user_project.deployments), with: Entities::Deployment
present paginate(user_project.deployments), with: ::API::V3::Deployments
end
desc 'Gets a specific deployment' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities::Deployment
success ::API::V3::Deployments
end
params do
requires :deployment_id, type: Integer, desc: 'The deployment ID'
......@@ -34,7 +34,7 @@ class Deployments < Grape::API
deployment = user_project.deployments.find(params[:deployment_id])
present deployment, with: Entities::Deployment
present deployment, with: ::API::V3::Deployments
end
end
end
......
......@@ -75,75 +75,6 @@
end
end
describe 'GET /projects/:id/repository/commits/:sha/jobs' do
context 'when commit does not exist in repository' do
before do
get api("/projects/#{project.id}/repository/commits/1a271fd1/jobs", api_user)
end
it 'responds with 404' do
expect(response).to have_http_status(404)
end
end
context 'when commit exists in repository' do
context 'when user is authorized' do
context 'when pipeline has jobs' do
before do
create(:ci_pipeline, project: project, sha: project.commit.id)
create(:ci_build, pipeline: pipeline)
create(:ci_build)
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/jobs", api_user)
end
it 'returns project jobs for specific commit' do
expect(response).to have_http_status(200)
expect(response).to include_pagination_headers
expect(json_response).to be_an Array
expect(json_response.size).to eq 2
end
it 'returns pipeline data' do
json_build = json_response.first
expect(json_build['pipeline']).not_to be_empty
expect(json_build['pipeline']['id']).to eq build.pipeline.id
expect(json_build['pipeline']['ref']).to eq build.pipeline.ref
expect(json_build['pipeline']['sha']).to eq build.pipeline.sha
expect(json_build['pipeline']['status']).to eq build.pipeline.status
end
end
context 'when pipeline has no jobs' do
before do
branch_head = project.commit('feature').id
get api("/projects/#{project.id}/repository/commits/#{branch_head}/jobs", api_user)
end
it 'returns an empty array' do
expect(response).to have_http_status(200)
expect(json_response).to be_an Array
expect(json_response).to be_empty
end
end
end
context 'when user is not authorized' do
before do
create(:ci_pipeline, project: project, sha: project.commit.id)
create(:ci_build, pipeline: pipeline)
get api("/projects/#{project.id}/repository/commits/#{project.commit.id}/jobs", nil)
end
it 'does not return project jobs' do
expect(response).to have_http_status(401)
expect(json_response.except('message')).to be_empty
end
end
end
end
describe 'GET /projects/:id/jobs/:job_id' do
before do
get api("/projects/#{project.id}/jobs/#{build.id}", api_user)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment