diff --git a/app/controllers/projects/pipelines_settings_controller.rb b/app/controllers/projects/pipelines_settings_controller.rb index c3c17afa025..bfc453215c8 100644 --- a/app/controllers/projects/pipelines_settings_controller.rb +++ b/app/controllers/projects/pipelines_settings_controller.rb @@ -23,7 +23,7 @@ class Projects::PipelinesSettingsController < Projects::ApplicationController def update_params params.require(:project).permit( :runners_token, :builds_enabled, :build_allow_git_fetch, :build_timeout_in_minutes, :build_coverage_regex, - :public_builds, :auto_cancel_pending_pipelines, :ci_config_file + :public_builds, :auto_cancel_pending_pipelines, :ci_config_path ) end end diff --git a/app/models/ci/pipeline.rb b/app/models/ci/pipeline.rb index 759fdb4bf4c..c5847dee7f7 100644 --- a/app/models/ci/pipeline.rb +++ b/app/models/ci/pipeline.rb @@ -327,10 +327,10 @@ module Ci end def ci_yaml_file_path - if project.ci_config_file.blank? + if project.ci_config_path.blank? '.gitlab-ci.yml' else - project.ci_config_file + project.ci_config_path end end diff --git a/app/models/project.rb b/app/models/project.rb index edc95980729..96400b07b18 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -186,7 +186,7 @@ class Project < ActiveRecord::Base # Validations validates :creator, presence: true, on: :create validates :description, length: { maximum: 2000 }, allow_blank: true - validates :ci_config_file, + validates :ci_config_path, format: { without: /\.{2}/, message: 'cannot include directory traversal.' }, length: { maximum: 255 }, @@ -526,7 +526,7 @@ class Project < ActiveRecord::Base import_data&.destroy end - def ci_config_file=(value) + def ci_config_path=(value) # Strip all leading slashes so that //foo -> foo super(value&.sub(%r{\A/+}, '')&.delete("\0")) end @@ -1025,7 +1025,7 @@ class Project < ActiveRecord::Base visibility_level: visibility_level, path_with_namespace: path_with_namespace, default_branch: default_branch, - ci_config_file: ci_config_file + ci_config_path: ci_config_path } # Backward compatibility diff --git a/app/views/projects/pipelines_settings/_show.html.haml b/app/views/projects/pipelines_settings/_show.html.haml index c9c8bd2610b..0d1c97df3ca 100644 --- a/app/views/projects/pipelines_settings/_show.html.haml +++ b/app/views/projects/pipelines_settings/_show.html.haml @@ -47,11 +47,11 @@ %hr .form-group - = f.label :ci_config_file, 'Custom CI config file', class: 'label-light' - = f.text_field :ci_config_file, class: 'form-control', placeholder: '.gitlab-ci.yml' + = f.label :ci_config_path, 'Custom CI config path', class: 'label-light' + = f.text_field :ci_config_path, class: 'form-control', placeholder: '.gitlab-ci.yml' %p.help-block The path to CI config file. Defaults to .gitlab-ci.yml - = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'custom-ci-config-file'), target: '_blank' + = link_to icon('question-circle'), help_page_path('user/project/pipelines/settings', anchor: 'custom-ci-config-path'), target: '_blank' %hr .form-group diff --git a/db/migrate/20160804142904_add_ci_config_file_to_project.rb b/db/migrate/20160804142904_add_ci_config_file_to_project.rb index 674a22ae8f3..341ae555c1b 100644 --- a/db/migrate/20160804142904_add_ci_config_file_to_project.rb +++ b/db/migrate/20160804142904_add_ci_config_file_to_project.rb @@ -2,10 +2,10 @@ class AddCiConfigFileToProject < ActiveRecord::Migration DOWNTIME = false def change - add_column :projects, :ci_config_file, :string + add_column :projects, :ci_config_path, :string end def down - remove_column :projects, :ci_config_file + remove_column :projects, :ci_config_path end end diff --git a/db/schema.rb b/db/schema.rb index 1c8f0ebfb9b..71555b21241 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -1085,7 +1085,7 @@ ActiveRecord::Schema.define(version: 20170622162730) do t.string "import_jid" t.integer "cached_markdown_version" t.datetime "last_repository_updated_at" - t.string "ci_config_file" + t.string "ci_config_path" end add_index "projects", ["ci_id"], name: "index_projects_on_ci_id", using: :btree diff --git a/doc/api/projects.md b/doc/api/projects.md index 7e626f54cda..c3a49354d0f 100644 --- a/doc/api/projects.md +++ b/doc/api/projects.md @@ -346,7 +346,7 @@ Parameters: | `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project | | `avatar` | mixed | no | Image file for avatar of the project | | `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line | -| `ci_config_file` | string | no | The path to CI config file | +| `ci_config_path` | string | no | The path to CI config file | ### Create project for user @@ -383,7 +383,7 @@ Parameters: | `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project | | `avatar` | mixed | no | Image file for avatar of the project | | `printing_merge_request_link_enabled` | boolean | no | Show link to create/view merge request when pushing from the command line | -| `ci_config_file` | string | no | The path to CI config file | +| `ci_config_path` | string | no | The path to CI config file | ### Edit project @@ -418,7 +418,7 @@ Parameters: | `request_access_enabled` | boolean | no | Allow users to request member access | | `tag_list` | array | no | The list of tags for a project; put array of tags, that should be finally assigned to a project | | `avatar` | mixed | no | Image file for avatar of the project | -| `ci_config_file` | string | no | The path to CI config file | +| `ci_config_path` | string | no | The path to CI config file | ### Fork project diff --git a/doc/user/project/pipelines/settings.md b/doc/user/project/pipelines/settings.md index 7274fe816cc..3ff5a08d72c 100644 --- a/doc/user/project/pipelines/settings.md +++ b/doc/user/project/pipelines/settings.md @@ -27,7 +27,7 @@ The default value is 60 minutes. Decrease the time limit if you want to impose a hard limit on your jobs' running time or increase it otherwise. In any case, if the job surpasses the threshold, it is marked as failed. -## Custom CI config file +## Custom CI config path > - [Introduced][ce-12509] in GitLab 9.4. diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 4ab264a3b98..78d2e6de44e 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -112,7 +112,7 @@ module API expose :open_issues_count, if: lambda { |project, options| project.feature_available?(:issues, options[:current_user]) && project.default_issues_tracker? } expose :runners_token, if: lambda { |_project, options| options[:user_can_admin_project] } expose :public_builds, as: :public_jobs - expose :ci_config_file + expose :ci_config_path expose :shared_with_groups do |project, options| SharedGroup.represent(project.project_group_links.all, options) end diff --git a/lib/api/projects.rb b/lib/api/projects.rb index efd133d81b3..35733ac7711 100644 --- a/lib/api/projects.rb +++ b/lib/api/projects.rb @@ -10,7 +10,7 @@ module API helpers do params :optional_params_ce do optional :description, type: String, desc: 'The description of the project' - optional :ci_config_file, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`' + optional :ci_config_path, type: String, desc: 'The path to CI config file. Defaults to `.gitlab-ci.yml`' optional :issues_enabled, type: Boolean, desc: 'Flag indication if the issue tracker is enabled' optional :merge_requests_enabled, type: Boolean, desc: 'Flag indication if merge requests are enabled' optional :wiki_enabled, type: Boolean, desc: 'Flag indication if the wiki is enabled' diff --git a/spec/lib/gitlab/import_export/safe_model_attributes.yml b/spec/lib/gitlab/import_export/safe_model_attributes.yml index f782cf533e8..697ddf52af9 100644 --- a/spec/lib/gitlab/import_export/safe_model_attributes.yml +++ b/spec/lib/gitlab/import_export/safe_model_attributes.yml @@ -383,7 +383,7 @@ Project: - printing_merge_request_link_enabled - build_allow_git_fetch - last_repository_updated_at -- ci_config_file +- ci_config_path Author: - name ProjectFeature: diff --git a/spec/models/ci/build_spec.rb b/spec/models/ci/build_spec.rb index e5fd549f0d7..f955d9c81b8 100644 --- a/spec/models/ci/build_spec.rb +++ b/spec/models/ci/build_spec.rb @@ -1474,7 +1474,7 @@ describe Ci::Build, :models do let(:ci_config_path) { { key: 'CI_CONFIG_PATH', value: 'custom', public: true } } before do - project.update(ci_config_file: 'custom') + project.update(ci_config_path: 'custom') end it { is_expected.to include(ci_config_path) } diff --git a/spec/models/ci/pipeline_spec.rb b/spec/models/ci/pipeline_spec.rb index a24b1e6c818..ba0696fa210 100644 --- a/spec/models/ci/pipeline_spec.rb +++ b/spec/models/ci/pipeline_spec.rb @@ -752,19 +752,19 @@ describe Ci::Pipeline, models: true do subject { pipeline.ci_yaml_file_path } it 'returns the path from project' do - allow(pipeline.project).to receive(:ci_config_file) { 'custom/path' } + allow(pipeline.project).to receive(:ci_config_path) { 'custom/path' } is_expected.to eq('custom/path') end it 'returns default when custom path is nil' do - allow(pipeline.project).to receive(:ci_config_file) { nil } + allow(pipeline.project).to receive(:ci_config_path) { nil } is_expected.to eq('.gitlab-ci.yml') end it 'returns default when custom path is empty' do - allow(pipeline.project).to receive(:ci_config_file) { '' } + allow(pipeline.project).to receive(:ci_config_path) { '' } is_expected.to eq('.gitlab-ci.yml') end @@ -772,7 +772,7 @@ describe Ci::Pipeline, models: true do describe '#ci_yaml_file' do it 'reports error if the file is not found' do - allow(pipeline.project).to receive(:ci_config_file) { 'custom' } + allow(pipeline.project).to receive(:ci_config_path) { 'custom' } pipeline.ci_yaml_file diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index a682fa82bf0..6197a390da8 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -143,9 +143,9 @@ describe Project, models: true do it { is_expected.to validate_length_of(:description).is_at_most(2000) } - it { is_expected.to validate_length_of(:ci_config_file).is_at_most(255) } - it { is_expected.to allow_value('').for(:ci_config_file) } - it { is_expected.not_to allow_value('test/../foo').for(:ci_config_file) } + it { is_expected.to validate_length_of(:ci_config_path).is_at_most(255) } + it { is_expected.to allow_value('').for(:ci_config_path) } + it { is_expected.not_to allow_value('test/../foo').for(:ci_config_path) } it { is_expected.to validate_presence_of(:creator) } @@ -1493,25 +1493,25 @@ describe Project, models: true do end end - describe '#ci_config_file=' do + describe '#ci_config_path=' do let(:project) { create(:empty_project) } it 'sets nil' do - project.update!(ci_config_file: nil) + project.update!(ci_config_path: nil) - expect(project.ci_config_file).to be_nil + expect(project.ci_config_path).to be_nil end it 'sets a string' do - project.update!(ci_config_file: 'foo/.gitlab_ci.yml') + project.update!(ci_config_path: 'foo/.gitlab_ci.yml') - expect(project.ci_config_file).to eq('foo/.gitlab_ci.yml') + expect(project.ci_config_path).to eq('foo/.gitlab_ci.yml') end it 'sets a string but remove all leading slashes and null characters' do - project.update!(ci_config_file: "///f\0oo/\0/.gitlab_ci.yml") + project.update!(ci_config_path: "///f\0oo/\0/.gitlab_ci.yml") - expect(project.ci_config_file).to eq('foo//.gitlab_ci.yml') + expect(project.ci_config_path).to eq('foo//.gitlab_ci.yml') end end diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb index d19ce2d9887..8ac65ecccab 100644 --- a/spec/requests/api/projects_spec.rb +++ b/spec/requests/api/projects_spec.rb @@ -348,7 +348,7 @@ describe API::Projects do only_allow_merge_if_pipeline_succeeds: false, request_access_enabled: true, only_allow_merge_if_all_discussions_are_resolved: false, - ci_config_file: 'a/custom/path' + ci_config_path: 'a/custom/path' }) post api('/projects', user), project @@ -654,7 +654,7 @@ describe API::Projects do expect(json_response['star_count']).to be_present expect(json_response['forks_count']).to be_present expect(json_response['public_jobs']).to be_present - expect(json_response['ci_config_file']).to be_nil + expect(json_response['ci_config_path']).to be_nil expect(json_response['shared_with_groups']).to be_an Array expect(json_response['shared_with_groups'].length).to eq(1) expect(json_response['shared_with_groups'][0]['group_id']).to eq(group.id)