Skip to content
Snippets Groups Projects
Commit 0a699980 authored by Manuel Grabowski's avatar Manuel Grabowski
Browse files

Fully deprecate `public_builds` in projects API

When we changed from `public_builds` to `public_jobs` in gitlab-foss!9463
we missed the `PUT` and `POST` endpoints. Internally we still refer to
it as `public_builds` and due to the breaking changes policy for the API
we will still need to support `public_builds` as an API parameter, so
using the `translate_params_for_compatibility()` method to support both
is a convenient way to achieve consistency without a large refactor.

Fixes #329725
parent d4d8ee73
No related branches found
No related tags found
2 merge requests!144312Change service start (cut-off) date for code suggestions to March 15th,!142819Fully deprecate `public_builds` in projects API
......@@ -1569,7 +1569,8 @@ curl --request POST --header "PRIVATE-TOKEN: <your-token>" \
| `packages_enabled` | boolean | No | Enable or disable packages repository feature. |
| `pages_access_level` | string | No | One of `disabled`, `private`, `enabled`, or `public`. |
| `printing_merge_request_link_enabled` | boolean | No | Show link to create/view merge request when pushing from the command line. |
| `public_builds` | boolean | No | If `true`, jobs can be viewed by non-project members. |
| `public_builds` | boolean | No | _(Deprecated)_ If `true`, jobs can be viewed by non-project members. Use `public_jobs` instead. |
| `public_jobs` | boolean | No | If `true`, jobs can be viewed by non-project members. |
| `releases_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
| `remove_source_branch_after_merge` | boolean | No | Enable `Delete source branch` option by default for all new merge requests. |
| `repository_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
......@@ -1661,7 +1662,8 @@ POST /projects/user/:user_id
| `pages_access_level` | string | No | One of `disabled`, `private`, `enabled`, or `public`. |
| `path` | string | No | Custom repository name for new project. By default generated based on name. |
| `printing_merge_request_link_enabled` | boolean | No | Show link to create/view merge request when pushing from the command line. |
| `public_builds` | boolean | No | If `true`, jobs can be viewed by non-project-members. |
| `public_builds` | boolean | No | _(Deprecated)_ If `true`, jobs can be viewed by non-project members. Use `public_jobs` instead. |
| `public_jobs` | boolean | No | If `true`, jobs can be viewed by non-project members. |
| `releases_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
| `remove_source_branch_after_merge` | boolean | No | Enable `Delete source branch` option by default for all new merge requests. |
| `repository_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
......@@ -1773,7 +1775,8 @@ Supported attributes:
| `path` | string | No | Custom repository name for the project. By default generated based on name. |
| `prevent_merge_without_jira_issue` | boolean | No | Set whether merge requests require an associated issue from Jira. Premium and Ultimate only. |
| `printing_merge_request_link_enabled` | boolean | No | Show link to create/view merge request when pushing from the command line. |
| `public_builds` | boolean | No | If `true`, jobs can be viewed by non-project members. |
| `public_builds` | boolean | No | _(Deprecated)_ If `true`, jobs can be viewed by non-project members. Use `public_jobs` instead. |
| `public_jobs` | boolean | No | If `true`, jobs can be viewed by non-project members. |
| `releases_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
| `environments_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
| `feature_flags_access_level` | string | No | One of `disabled`, `private`, or `enabled`. |
......
......@@ -58,7 +58,8 @@ module ProjectsHelpers
end
optional :lfs_enabled, type: Boolean, desc: 'Flag indication if Git LFS is enabled for that project'
optional :visibility, type: String, values: Gitlab::VisibilityLevel.string_values, desc: 'The visibility of the project.'
optional :public_builds, type: Boolean, desc: 'Perform public builds'
optional :public_builds, type: Boolean, desc: 'Deprecated: Use public_jobs instead.'
optional :public_jobs, type: Boolean, desc: 'Perform public builds'
optional :request_access_enabled, type: Boolean, desc: 'Allow users to request member access'
optional :only_allow_merge_if_pipeline_succeeds, type: Boolean, desc: 'Only allow to merge if builds succeed'
optional :allow_merge_on_skipped_pipeline, type: Boolean, desc: 'Allow to merge if pipeline is skipped'
......@@ -165,7 +166,8 @@ def self.update_params_at_least_one_of
:pages_access_level,
:path,
:printing_merge_request_link_enabled,
:public_builds,
:public_builds, # deprecated
:public_jobs,
:remove_source_branch_after_merge,
:repository_access_level,
:request_access_enabled,
......
......@@ -222,6 +222,7 @@ def present_groups(groups)
def translate_params_for_compatibility(params)
params[:builds_enabled] = params.delete(:jobs_enabled) if params.key?(:jobs_enabled)
params[:emails_enabled] = !params.delete(:emails_disabled) if params.key?(:emails_disabled)
params[:public_builds] = params.delete(:public_jobs) if params.key?(:public_jobs)
params
end
......
......@@ -4161,6 +4161,28 @@ def failure_message(diff)
end
end
it 'updates public_builds (deprecated)' do
project3.update!({ public_builds: false })
project_param = { public_builds: 'true' }
put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['public_jobs']).to be_truthy
end
it 'updates public_jobs' do
project3.update!({ public_builds: false })
project_param = { public_jobs: 'true' }
put api("/projects/#{project3.id}", user), params: project_param
expect(response).to have_gitlab_http_status(:ok)
expect(json_response['public_jobs']).to be_truthy
end
context 'with changes to the avatar' do
let_it_be(:avatar_file) { fixture_file_upload('spec/fixtures/banana_sample.gif', 'image/gif') }
let_it_be(:alternate_avatar_file) { fixture_file_upload('spec/fixtures/rails_sample.png', 'image/png') }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment