summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-19 00:15:49 +0200
committerDmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>2015-09-19 00:15:49 +0200
commit442db0801aea1f11163e7e128da6cbcf2823c5cd (patch)
tree95f63e0438dcb3a157d72d4382662a22c73a5cb5
parent6776dcf90b9e101b8c9341ea83621e48f87584d6 (diff)
parent5a8d73243a7b68f2724a6d5f9d482dda24e9dfe4 (diff)
downloadgitlab-ce-442db0801aea1f11163e7e128da6cbcf2823c5cd.tar.gz
Merge branch 'master' into ci-build-list
-rw-r--r--CHANGELOG2
-rw-r--r--app/assets/javascripts/issuable_context.js.coffee9
-rw-r--r--app/controllers/admin/application_settings_controller.rb1
-rw-r--r--app/controllers/ci/application_controller.rb9
-rw-r--r--app/controllers/ci/projects_controller.rb20
-rw-r--r--app/models/application_setting.rb3
-rw-r--r--app/models/ci/project.rb15
-rw-r--r--app/models/project_services/buildkite_service.rb8
-rw-r--r--app/models/project_services/drone_ci_service.rb14
-rw-r--r--app/models/project_services/gitlab_ci_service.rb86
-rw-r--r--app/services/ci/create_project_service.rb9
-rw-r--r--app/services/projects/fork_service.rb2
-rw-r--r--app/views/admin/application_settings/_form.html.haml9
-rw-r--r--app/views/ci/projects/disabled.html.haml1
-rw-r--r--app/views/layouts/ci/application.html.haml2
-rw-r--r--app/views/layouts/nav/_dashboard.html.haml2
-rw-r--r--app/workers/fork_registration_worker.rb12
-rw-r--r--config/gitlab.yml.example1
-rw-r--r--config/initializers/1_settings.rb2
-rw-r--r--config/routes.rb3
-rw-r--r--db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb5
-rw-r--r--db/schema.rb3
-rw-r--r--doc/ci/api/README.md1
-rw-r--r--doc/ci/api/forks.md23
-rw-r--r--doc/reply_by_email/postfix.md4
-rw-r--r--features/steps/project/services.rb4
-rw-r--r--lib/backup/database.rb8
-rw-r--r--lib/ci/api/api.rb5
-rw-r--r--lib/ci/api/forks.rb37
-rw-r--r--lib/ci/api/helpers.rb6
-rw-r--r--spec/controllers/ci/projects_controller_spec.rb43
-rw-r--r--spec/lib/gitlab/backend/grack_auth_spec.rb1
-rw-r--r--spec/models/project_services/buildkite_service_spec.rb14
-rw-r--r--spec/models/project_services/gitlab_ci_service_spec.rb50
-rw-r--r--spec/requests/api/projects_spec.rb2
-rw-r--r--spec/requests/api/services_spec.rb4
-rw-r--r--spec/requests/ci/api/forks_spec.rb59
-rw-r--r--spec/services/ci/create_project_service_spec.rb4
-rw-r--r--spec/services/projects/fork_service_spec.rb3
-rw-r--r--spec/workers/fork_registration_worker_spec.rb10
40 files changed, 109 insertions, 387 deletions
diff --git a/CHANGELOG b/CHANGELOG
index 811089bbc61..a1b17e58156 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -54,6 +54,8 @@ v 8.0.0 (unreleased)
- Sort users autocomplete lists by user (Allister Antosik)
- Webhook for issue now contains repository field (Jungkook Park)
- Add ability to add custom text to the help page (Jeroen van Baarsen)
+ - Add pg_schema to backup config
+ - Removed API calls from CE to CI
v 7.14.3
- No changes
diff --git a/app/assets/javascripts/issuable_context.js.coffee b/app/assets/javascripts/issuable_context.js.coffee
index 176d9cabefa..c4d3e619f5e 100644
--- a/app/assets/javascripts/issuable_context.js.coffee
+++ b/app/assets/javascripts/issuable_context.js.coffee
@@ -11,12 +11,13 @@ class @IssuableContext
$(this).submit()
$('.issuable-details').waitForImages ->
+ $('.issuable-affix').on 'affix.bs.affix', ->
+ $(@).width($(@).outerWidth())
+ .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
+ $(@).width('')
+
$('.issuable-affix').affix offset:
top: ->
@top = ($('.issuable-affix').offset().top - 70)
bottom: ->
@bottom = $('.footer').outerHeight(true)
- $('.issuable-affix').on 'affix.bs.affix', ->
- $(@).width($(@).outerWidth())
- .on 'affixed-top.bs.affix affixed-bottom.bs.affix', ->
- $(@).width('')
diff --git a/app/controllers/admin/application_settings_controller.rb b/app/controllers/admin/application_settings_controller.rb
index 7c134d2ec9b..5f70582cbb7 100644
--- a/app/controllers/admin/application_settings_controller.rb
+++ b/app/controllers/admin/application_settings_controller.rb
@@ -56,6 +56,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:restricted_signup_domains_raw,
:version_check_enabled,
:user_oauth_applications,
+ :ci_enabled,
restricted_visibility_levels: [],
import_sources: []
)
diff --git a/app/controllers/ci/application_controller.rb b/app/controllers/ci/application_controller.rb
index d45c4e9caf1..8d8ff75ff72 100644
--- a/app/controllers/ci/application_controller.rb
+++ b/app/controllers/ci/application_controller.rb
@@ -1,5 +1,7 @@
module Ci
class ApplicationController < ::ApplicationController
+ before_action :check_enable_flag!
+
def self.railtie_helpers_paths
"app/helpers/ci"
end
@@ -8,6 +10,13 @@ module Ci
private
+ def check_enable_flag!
+ unless current_application_settings.ci_enabled
+ redirect_to(disabled_ci_projects_path)
+ return
+ end
+ end
+
def authenticate_public_page!
unless project.public
authenticate_user!
diff --git a/app/controllers/ci/projects_controller.rb b/app/controllers/ci/projects_controller.rb
index 653384b7178..40b61edb0a9 100644
--- a/app/controllers/ci/projects_controller.rb
+++ b/app/controllers/ci/projects_controller.rb
@@ -5,13 +5,17 @@ module Ci
before_action :authenticate_user!, except: [:build, :badge, :index, :show]
before_action :authenticate_public_page!, only: :show
before_action :project, only: [:build, :integration, :show, :badge, :edit, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
- before_action :authorize_access_project!, except: [:build, :badge, :index, :show, :new, :create]
+ before_action :authorize_access_project!, except: [:build, :badge, :index, :show, :new, :create, :disabled]
before_action :authorize_manage_project!, only: [:edit, :integration, :update, :destroy, :toggle_shared_runners, :dumped_yaml]
before_action :authenticate_token!, only: [:build]
before_action :no_cache, only: [:badge]
+ skip_before_action :check_enable_flag!, only: [:disabled]
protect_from_forgery except: :build
- layout 'ci/project', except: :index
+ layout 'ci/project', except: [:index, :disabled]
+
+ def disabled
+ end
def index
@limit, @offset = (params[:limit] || PROJECTS_BATCH).to_i, (params[:offset] || 0).to_i
@@ -51,7 +55,7 @@ module Ci
return redirect_to ci_root_path, alert: 'You have to have at least master role to enable CI for this project'
end
- @project = Ci::CreateProjectService.new.execute(current_user, project_data, ci_project_url(":project_id"))
+ @project = Ci::CreateProjectService.new.execute(current_user, project_data)
if @project.persisted?
redirect_to ci_project_path(@project, show_guide: true), notice: 'Project was successfully created.'
@@ -82,16 +86,6 @@ module Ci
redirect_to ci_projects_url
end
- def build
- @commit = Ci::CreateCommitService.new.execute(@project, params.dup)
-
- if @commit && @commit.valid?
- head 201
- else
- head 400
- end
- end
-
# Project status badge
# Image with build status for sha or ref
def badge
diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb
index c8841178e93..784f5c96a0a 100644
--- a/app/models/application_setting.rb
+++ b/app/models/application_setting.rb
@@ -83,7 +83,8 @@ class ApplicationSetting < ActiveRecord::Base
default_project_visibility: Settings.gitlab.default_projects_features['visibility_level'],
default_snippet_visibility: Settings.gitlab.default_projects_features['visibility_level'],
restricted_signup_domains: Settings.gitlab['restricted_signup_domains'],
- import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git']
+ import_sources: ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'],
+ ci_enabled: Settings.gitlab_ci['enabled']
)
end
diff --git a/app/models/ci/project.rb b/app/models/ci/project.rb
index ae901d4ccd0..37fbcc287bb 100644
--- a/app/models/ci/project.rb
+++ b/app/models/ci/project.rb
@@ -92,21 +92,6 @@ module Ci
project
end
- # TODO: remove
- def from_gitlab(user, scope = :owned, options)
- opts = user.authenticate_options
- opts.merge! options
-
- raise 'Implement me of fix'
- #projects = Ci::Network.new.projects(opts.compact, scope)
-
- if projects
- projects.map { |pr| OpenStruct.new(pr) }
- else
- []
- end
- end
-
def already_added?(project)
where(gitlab_id: project.id).any?
end
diff --git a/app/models/project_services/buildkite_service.rb b/app/models/project_services/buildkite_service.rb
index 9e5da6f45d2..40058b53df5 100644
--- a/app/models/project_services/buildkite_service.rb
+++ b/app/models/project_services/buildkite_service.rb
@@ -69,14 +69,6 @@ class BuildkiteService < CiService
"#{project_url}/builds?commit=#{sha}"
end
- def builds_path
- "#{project_url}/builds?branch=#{project.default_branch}"
- end
-
- def status_img_path
- "#{buildkite_endpoint('badge')}/#{status_token}.svg"
- end
-
def title
'Buildkite'
end
diff --git a/app/models/project_services/drone_ci_service.rb b/app/models/project_services/drone_ci_service.rb
index 3e2b7faecdb..b13fa3e9ecb 100644
--- a/app/models/project_services/drone_ci_service.rb
+++ b/app/models/project_services/drone_ci_service.rb
@@ -135,20 +135,6 @@ class DroneCiService < CiService
commit_page(sha, ref)
end
- def builds_path
- url = [drone_url, "#{project.namespace.path}/#{project.path}"]
-
- URI.join(*url).to_s
- end
-
- def status_img_path
- url = [drone_url,
- "api/badges/#{project.namespace.path}/#{project.path}/status.svg",
- "?branch=#{URI::encode(project.default_branch)}"]
-
- URI.join(*url).to_s
- end
-
def title
'Drone CI'
end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index acbbc9935b6..820dd3f567c 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -19,22 +19,12 @@
#
class GitlabCiService < CiService
- API_PREFIX = "api/v1"
-
- prop_accessor :project_url, :token, :enable_ssl_verification
- validates :project_url,
- presence: true,
- format: { with: /\A#{URI.regexp(%w(http https))}\z/, message: "should be a valid url" }, if: :activated?
- validates :token,
- presence: true,
- format: { with: /\A([A-Za-z0-9]+)\z/ }, if: :activated?
+ prop_accessor :token
after_save :compose_service_hook, if: :activated?
def compose_service_hook
hook = service_hook || build_service_hook
- hook.url = [project_url, "/build", "?token=#{token}"].join("")
- hook.enable_ssl_verification = enable_ssl_verification
hook.save
end
@@ -55,71 +45,47 @@ class GitlabCiService < CiService
end
end
- service_hook.execute(data)
- end
-
- def commit_status_path(sha, ref)
- URI::encode(project_url + "/refs/#{ref}/commits/#{sha}/status.json?token=#{token}")
+ ci_project = Ci::Project.find_by(gitlab_id: project.id)
+ Ci::CreateCommitService.new.execute(ci_project, data)
end
- def get_ci_build(sha, ref)
- @ci_builds ||= {}
- @ci_builds[sha] ||= HTTParty.get(commit_status_path(sha, ref), verify: false)
+ def get_ci_commit(sha, ref)
+ Ci::Project.find(project.gitlab_ci_project).commits.find_by_sha_and_ref!(sha, ref)
end
def commit_status(sha, ref)
- response = get_ci_build(sha, ref)
-
- if response.code == 200 and response["status"]
- response["status"]
- else
- :error
- end
- rescue Errno::ECONNREFUSED
+ get_ci_commit(sha, ref).status
+ rescue ActiveRecord::RecordNotFound
:error
end
- def fork_registration(new_project, private_token)
- params = {
+ def fork_registration(new_project, current_user)
+ params = OpenStruct.new({
id: new_project.id,
name_with_namespace: new_project.name_with_namespace,
path_with_namespace: new_project.path_with_namespace,
web_url: new_project.web_url,
default_branch: new_project.default_branch,
ssh_url_to_repo: new_project.ssh_url_to_repo
- }
-
- HTTParty.post(
- fork_registration_path,
- body: {
- project_id: project.id,
- project_token: token,
- private_token: private_token,
- data: params },
- verify: false
+ })
+
+ ci_project = Ci::Project.find_by!(gitlab_id: project.id)
+
+ Ci::CreateProjectService.new.execute(
+ current_user,
+ params,
+ ci_project
)
end
def commit_coverage(sha, ref)
- response = get_ci_build(sha, ref)
-
- if response.code == 200 and response["coverage"]
- response["coverage"]
- end
- rescue Errno::ECONNREFUSED
- nil
+ get_ci_commit(sha, ref).coverage
+ rescue ActiveRecord::RecordNotFound
+ :error
end
def build_page(sha, ref)
- URI::encode(project_url + "/refs/#{ref}/commits/#{sha}")
- end
-
- def builds_path
- project_url + "?ref=" + project.default_branch
- end
-
- def status_img_path
- project_url + "/status.png?ref=" + project.default_branch
+ Ci::RoutesHelper.ci_project_ref_commits_path(project.gitlab_ci_project, ref, sha)
end
def title
@@ -135,11 +101,7 @@ class GitlabCiService < CiService
end
def fields
- [
- { type: 'text', name: 'token', placeholder: 'GitLab CI project specific token' },
- { type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3' },
- { type: 'checkbox', name: 'enable_ssl_verification', title: "Enable SSL verification" }
- ]
+ []
end
private
@@ -148,10 +110,6 @@ class GitlabCiService < CiService
repository.blob_at(sha, '.gitlab-ci.yml')
end
- def fork_registration_path
- project_url.sub(/projects\/\d*/, "#{API_PREFIX}/forks")
- end
-
def repository
project.repository
end
diff --git a/app/services/ci/create_project_service.rb b/app/services/ci/create_project_service.rb
index 0419612d521..839d3f6b444 100644
--- a/app/services/ci/create_project_service.rb
+++ b/app/services/ci/create_project_service.rb
@@ -2,20 +2,15 @@ module Ci
class CreateProjectService
include Gitlab::Application.routes.url_helpers
- def execute(current_user, params, project_route, forked_project = nil)
+ def execute(current_user, params, forked_project = nil)
@project = Ci::Project.parse(params)
Ci::Project.transaction do
@project.save!
- data = {
- token: @project.token,
- project_url: project_route.gsub(":project_id", @project.id.to_s),
- }
-
gl_project = ::Project.find(@project.gitlab_id)
gl_project.build_missing_services
- gl_project.gitlab_ci_service.update_attributes(data.merge(active: true))
+ gl_project.gitlab_ci_service.update_attributes(active: true, token: @project.token)
end
if forked_project
diff --git a/app/services/projects/fork_service.rb b/app/services/projects/fork_service.rb
index 50f208b11d1..2e995d6fd51 100644
--- a/app/services/projects/fork_service.rb
+++ b/app/services/projects/fork_service.rb
@@ -18,7 +18,7 @@ module Projects
if new_project.persisted?
if @project.gitlab_ci?
- ForkRegistrationWorker.perform_async(@project.id, new_project.id, @current_user.private_token)
+ @project.gitlab_ci_service.fork_registration(new_project, @current_user)
end
end
diff --git a/app/views/admin/application_settings/_form.html.haml b/app/views/admin/application_settings/_form.html.haml
index a36ae0b766c..1476e29524c 100644
--- a/app/views/admin/application_settings/_form.html.haml
+++ b/app/views/admin/application_settings/_form.html.haml
@@ -124,5 +124,14 @@
= f.text_area :help_page_text, class: 'form-control', rows: 4
.help-block Markdown enabled
+ %fieldset
+ %legend Continuous Integration
+ .form-group
+ .col-sm-offset-2.col-sm-10
+ .checkbox
+ = f.label :ci_enabled do
+ = f.check_box :ci_enabled
+ Enable Continuous Integration
+
.form-actions
= f.submit 'Save', class: 'btn btn-primary'
diff --git a/app/views/ci/projects/disabled.html.haml b/app/views/ci/projects/disabled.html.haml
new file mode 100644
index 00000000000..95276d894ed
--- /dev/null
+++ b/app/views/ci/projects/disabled.html.haml
@@ -0,0 +1 @@
+Continuous Integration has been disabled. Please ask your administrator to enable it.
diff --git a/app/views/layouts/ci/application.html.haml b/app/views/layouts/ci/application.html.haml
index 9cc7fb85142..38023468d0b 100644
--- a/app/views/layouts/ci/application.html.haml
+++ b/app/views/layouts/ci/application.html.haml
@@ -2,7 +2,7 @@
%html{ lang: "en"}
= render 'layouts/head'
%body{class: "ci-body #{user_application_theme}", 'data-page' => body_data_page}
- - header_title = "CI Projects"
+ - header_title = "Continuous Integration"
- if current_user
= render "layouts/header/default", title: header_title
- else
diff --git a/app/views/layouts/nav/_dashboard.html.haml b/app/views/layouts/nav/_dashboard.html.haml
index 3bda7c46959..b94165aac39 100644
--- a/app/views/layouts/nav/_dashboard.html.haml
+++ b/app/views/layouts/nav/_dashboard.html.haml
@@ -31,7 +31,7 @@
%span
Merge Requests
%span.count= current_user.assigned_merge_requests.opened.count
- = nav_link(path: 'ci/projects#index') do
+ = nav_link(path: ['ci/projects#index', 'ci/projects#disabled']) do
= link_to ci_projects_path, title: 'Continuous Integration', data: {placement: 'right'} do
= icon('building fw')
%span
diff --git a/app/workers/fork_registration_worker.rb b/app/workers/fork_registration_worker.rb
deleted file mode 100644
index fffa8b3a659..00000000000
--- a/app/workers/fork_registration_worker.rb
+++ /dev/null
@@ -1,12 +0,0 @@
-class ForkRegistrationWorker
- include Sidekiq::Worker
-
- sidekiq_options queue: :default
-
- def perform(from_project_id, to_project_id, private_token)
- from_project = Project.find(from_project_id)
- to_project = Project.find(to_project_id)
-
- from_project.gitlab_ci_service.fork_registration(to_project, private_token)
- end
-end
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index 0005d44e0f2..eada70faebc 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -306,6 +306,7 @@ production: &base
path: "tmp/backups" # Relative paths are relative to Rails.root (default: tmp/backups/)
# archive_permissions: 0640 # Permissions for the resulting backup.tar file (default: 0600)
# keep_time: 604800 # default: 0 (forever) (in seconds)
+ # pg_schema: public # default: nil, it means that all schemas will be backed up
# upload:
# # Fog storage connection settings, see http://fog.io/storage/ .
# connection:
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index fe81ffd4205..ddc9bbf5dfd 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -178,6 +178,7 @@ Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious'
# CI
#
Settings['gitlab_ci'] ||= Settingslogic.new({})
+Settings.gitlab_ci['enabled'] = true if Settings.gitlab_ci['enabled'].nil?
Settings.gitlab_ci['all_broken_builds'] = true if Settings.gitlab_ci['all_broken_builds'].nil?
Settings.gitlab_ci['add_pusher'] = false if Settings.gitlab_ci['add_pusher'].nil?
Settings.gitlab_ci['url'] ||= Settings.send(:build_gitlab_ci_url)
@@ -219,6 +220,7 @@ Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_s
#
Settings['backup'] ||= Settingslogic.new({})
Settings.backup['keep_time'] ||= 0
+Settings.backup['pg_schema'] = nil
Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root)
Settings.backup['archive_permissions'] ||= 0600
Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil })
diff --git a/config/routes.rb b/config/routes.rb
index b5a84c1f192..512dda7b547 100644
--- a/config/routes.rb
+++ b/config/routes.rb
@@ -12,13 +12,12 @@ Gitlab::Application.routes.draw do
resources :projects do
collection do
post :add
- get :gitlab
+ get :disabled
end
member do
get :status, to: 'projects#badge'
get :integration
- post :build
post :toggle_shared_runners
get :dumped_yaml
end
diff --git a/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb b/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb
new file mode 100644
index 00000000000..6cf668a170e
--- /dev/null
+++ b/db/migrate/20150918084513_add_ci_enabled_to_application_settings.rb
@@ -0,0 +1,5 @@
+class AddCiEnabledToApplicationSettings < ActiveRecord::Migration
+ def change
+ add_column :application_settings, :ci_enabled, :boolean, null: false, default: true
+ end
+end
diff --git a/db/schema.rb b/db/schema.rb
index bf5a88f10e8..d70c4b58e93 100644
--- a/db/schema.rb
+++ b/db/schema.rb
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
-ActiveRecord::Schema.define(version: 20150916145038) do
+ActiveRecord::Schema.define(version: 20150918084513) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"
@@ -46,6 +46,7 @@ ActiveRecord::Schema.define(version: 20150916145038) do
t.integer "session_expire_delay", default: 10080, null: false
t.text "import_sources"
t.text "help_page_text"
+ t.boolean "ci_enabled", default: true, null: false
end
create_table "audit_events", force: true do |t|
diff --git a/doc/ci/api/README.md b/doc/ci/api/README.md
index e47e5c46732..33c5b172e98 100644
--- a/doc/ci/api/README.md
+++ b/doc/ci/api/README.md
@@ -6,7 +6,6 @@
- [Runners](runners.md)
- [Commits](commits.md)
- [Builds](builds.md)
-- [Forks](forks.md)
## Authentication
diff --git a/doc/ci/api/forks.md b/doc/ci/api/forks.md
deleted file mode 100644
index 8f32e2d3b40..00000000000
--- a/doc/ci/api/forks.md
+++ /dev/null
@@ -1,23 +0,0 @@
-# Forks API
-
-This API is intended to aid in the setup and configuration of
-forked projects on Gitlab CI.
-
-__Authentication is done by GitLab user token & GitLab project token__
-
-## Forks
-
-### Create fork for project
-
-
-
-```
-POST /ci/forks
-```
-
-Parameters:
-
- project_id (required) - The ID of a project
- project_token (requires) - Project token
- private_token(required) - User private token
- data (required) - GitLab project data (name_with_namespace, web_url, default_branch, ssh_url_to_repo)
diff --git a/doc/reply_by_email/postfix.md b/doc/reply_by_email/postfix.md
index b8ab07d9fe1..c0ac59bb922 100644
--- a/doc/reply_by_email/postfix.md
+++ b/doc/reply_by_email/postfix.md
@@ -303,8 +303,8 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
## Done!
-If all the tests were successfull, Postfix is all set up and ready to receive email! Continue with the [Reply by email](./README.md) guide to configure GitLab.
+If all the tests were successful, Postfix is all set up and ready to receive email! Continue with the [Reply by email](./README.md) guide to configure GitLab.
---------
-_This document was adapted from https://help.ubuntu.com/community/PostfixBasicSetupHowto, by contributors to the Ubuntu documentation wiki._
+_This document was adapted from https://help.ubuntu.com/community/PostfixBasicSetupHowto, by contributors to the Ubuntu documentation wiki._ \ No newline at end of file
diff --git a/features/steps/project/services.rb b/features/steps/project/services.rb
index 0327fd61981..d3b462bfd31 100644
--- a/features/steps/project/services.rb
+++ b/features/steps/project/services.rb
@@ -26,13 +26,11 @@ class Spinach::Features::ProjectServices < Spinach::FeatureSteps
step 'I fill gitlab-ci settings' do
check 'Active'
- fill_in 'Project url', with: 'http://ci.gitlab.org/projects/3'
- fill_in 'Token', with: 'verySecret'
click_button 'Save'
end
step 'I should see service settings saved' do
- expect(find_field('Project url').value).to eq 'http://ci.gitlab.org/projects/3'
+ expect(find_field('Active').value).to eq '1'
end
step 'I click hipchat service link' do
diff --git a/lib/backup/database.rb b/lib/backup/database.rb
index ce75476a09b..959ac4b7868 100644
--- a/lib/backup/database.rb
+++ b/lib/backup/database.rb
@@ -25,8 +25,12 @@ module Backup
when "postgresql" then
$progress.print "Dumping PostgreSQL database #{config['database']} ... "
pg_env
- # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
- system('pg_dump', '--clean', config['database'], out: db_file_name)
+ pgsql_args = ["--clean"] # Pass '--clean' to include 'DROP TABLE' statements in the DB dump.
+ if Gitlab.config.backup.pg_schema
+ pgsql_args << "-n"
+ pgsql_args << Gitlab.config.backup.pg_schema
+ end
+ system('pg_dump', *pgsql_args, config['database'], out: db_file_name)
end
report_success(success)
abort 'Backup failed' unless success
diff --git a/lib/ci/api/api.rb b/lib/ci/api/api.rb
index 172c6f22164..5109c84e0ea 100644
--- a/lib/ci/api/api.rb
+++ b/lib/ci/api/api.rb
@@ -23,6 +23,10 @@ module Ci
rack_response({ 'message' => '500 Internal Server Error' }, 500)
end
+ before do
+ check_enable_flag!
+ end
+
format :json
helpers Helpers
@@ -32,7 +36,6 @@ module Ci
mount Commits
mount Runners
mount Projects
- mount Forks
mount Triggers
end
end
diff --git a/lib/ci/api/forks.rb b/lib/ci/api/forks.rb
deleted file mode 100644
index 152883a599f..00000000000
--- a/lib/ci/api/forks.rb
+++ /dev/null
@@ -1,37 +0,0 @@
-module Ci
- module API
- class Forks < Grape::API
- resource :forks do
- # Create a fork
- #
- # Parameters:
- # project_id (required) - The ID of a project
- # project_token (requires) - Project token
- # private_token(required) - User private token
- # data (required) - GitLab project data (name_with_namespace, web_url, default_branch, ssh_url_to_repo)
- #
- #
- # Example Request:
- # POST /forks
- post do
- required_attributes! [:project_id, :data, :project_token, :private_token]
- project = Ci::Project.find_by!(gitlab_id: params[:project_id])
- authenticate_project_token!(project)
-
- fork = Ci::CreateProjectService.new.execute(
- current_user,
- params[:data],
- Ci::RoutesHelper.ci_project_url(":project_id"),
- project
- )
-
- if fork
- present fork, with: Entities::Project
- else
- not_found!
- end
- end
- end
- end
- end
-end
diff --git a/lib/ci/api/helpers.rb b/lib/ci/api/helpers.rb
index e602cda81d6..8e893aa5cc6 100644
--- a/lib/ci/api/helpers.rb
+++ b/lib/ci/api/helpers.rb
@@ -3,6 +3,12 @@ module Ci
module Helpers
UPDATE_RUNNER_EVERY = 60
+ def check_enable_flag!
+ unless current_application_settings.ci_enabled
+ render_api_error!('400 (Bad request) CI is disabled', 400)
+ end
+ end
+
def authenticate_runners!
forbidden! unless params[:token] == GitlabCi::REGISTRATION_TOKEN
end
diff --git a/spec/controllers/ci/projects_controller_spec.rb b/spec/controllers/ci/projects_controller_spec.rb
index c7a3cd50c20..3e579f9a7d6 100644
--- a/spec/controllers/ci/projects_controller_spec.rb
+++ b/spec/controllers/ci/projects_controller_spec.rb
@@ -5,49 +5,6 @@ describe Ci::ProjectsController do
@project = FactoryGirl.create :ci_project
end
- describe "POST #build" do
- it 'should respond 200 if params is ok' do
- post :build, {
- id: @project.id,
- ref: 'master',
- before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
- after: '1c8a9df454ef68c22c2a33cca8232bb50849e5c5',
- token: @project.token,
- ci_yaml_file: gitlab_ci_yaml,
- commits: [ { message: "Message" } ]
- }
-
- expect(response).to be_success
- expect(response.code).to eq('201')
- end
-
- it 'should respond 400 if push about removed branch' do
- post :build, {
- id: @project.id,
- ref: 'master',
- before: '2aa371379db71ac89ae20843fcff3b3477cf1a1d',
- after: '0000000000000000000000000000000000000000',
- token: @project.token,
- ci_yaml_file: gitlab_ci_yaml
- }
-
- expect(response).not_to be_success
- expect(response.code).to eq('400')
- end
-
- it 'should respond 400 if some params missed' do
- post :build, id: @project.id, token: @project.token, ci_yaml_file: gitlab_ci_yaml
- expect(response).not_to be_success
- expect(response.code).to eq('400')
- end
-
- it 'should respond 403 if token is wrong' do
- post :build, id: @project.id, token: 'invalid-token'
- expect(response).not_to be_success
- expect(response.code).to eq('403')
- end
- end
-
describe "POST /projects" do
let(:project_dump) { OpenStruct.new({ id: @project.gitlab_id }) }
diff --git a/spec/lib/gitlab/backend/grack_auth_spec.rb b/spec/lib/gitlab/backend/grack_auth_spec.rb
index d9676445908..9bed8f8ee5c 100644
--- a/spec/lib/gitlab/backend/grack_auth_spec.rb
+++ b/spec/lib/gitlab/backend/grack_auth_spec.rb
@@ -180,7 +180,6 @@ describe Grack::Auth do
gitlab_ci_service = project.build_gitlab_ci_service
gitlab_ci_service.active = true
gitlab_ci_service.token = token
- gitlab_ci_service.project_url = "http://google.com"
gitlab_ci_service.save
env["HTTP_AUTHORIZATION"] = ActionController::HttpAuthentication::Basic.encode_credentials("gitlab-ci-token", token)
diff --git a/spec/models/project_services/buildkite_service_spec.rb b/spec/models/project_services/buildkite_service_spec.rb
index 9445d96c337..230807ea672 100644
--- a/spec/models/project_services/buildkite_service_spec.rb
+++ b/spec/models/project_services/buildkite_service_spec.rb
@@ -63,19 +63,5 @@ describe BuildkiteService do
)
end
end
-
- describe :builds_page do
- it 'returns the correct path to the builds page' do
- expect(@service.builds_path).to eq(
- 'https://buildkite.com/account-name/example-project/builds?branch=default-brancho'
- )
- end
- end
-
- describe :status_img_path do
- it 'returns the correct path to the status image' do
- expect(@service.status_img_path).to eq('https://badge.buildkite.com/secret-sauce-status-token.svg')
- end
- end
end
end
diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb
index a14384c87b4..e0da04a3f40 100644
--- a/spec/models/project_services/gitlab_ci_service_spec.rb
+++ b/spec/models/project_services/gitlab_ci_service_spec.rb
@@ -26,51 +26,21 @@ describe GitlabCiService do
it { is_expected.to have_one(:service_hook) }
end
- describe 'validations' do
- context 'active' do
- before { allow(subject).to receive(:activated?).and_return(true) }
-
- it { is_expected.to validate_presence_of(:token) }
- it { is_expected.to validate_presence_of(:project_url) }
- it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
- it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
- it { is_expected.not_to allow_value('token with spaces').for(:token) }
- it { is_expected.not_to allow_value('token/with%spaces').for(:token) }
- it { is_expected.not_to allow_value('this is not url').for(:project_url) }
- it { is_expected.not_to allow_value('http//noturl').for(:project_url) }
- it { is_expected.not_to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
- end
-
- context 'inactive' do
- before { allow(subject).to receive(:activated?).and_return(false) }
-
- it { is_expected.not_to validate_presence_of(:token) }
- it { is_expected.not_to validate_presence_of(:project_url) }
- it { is_expected.to allow_value('ewf9843kdnfdfs89234n').for(:token) }
- it { is_expected.to allow_value('http://ci.example.com/project/1').for(:project_url) }
- it { is_expected.to allow_value('token with spaces').for(:token) }
- it { is_expected.to allow_value('ftp://ci.example.com/projects/3').for(:project_url) }
- end
- end
-
describe 'commits methods' do
before do
+ @ci_project = create(:ci_project)
@service = GitlabCiService.new
allow(@service).to receive_messages(
service_hook: true,
project_url: 'http://ci.gitlab.org/projects/2',
- token: 'verySecret'
+ token: 'verySecret',
+ project: @ci_project.gl_project
)
end
- describe :commit_status_path do
- it { expect(@service.commit_status_path("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c/status.json?token=verySecret")}
- it { expect(@service.commit_status_path("issue#2", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/issue%232/status.json?token=verySecret")}
- end
-
describe :build_page do
- it { expect(@service.build_page("2ab7834c", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/2ab7834c")}
- it { expect(@service.build_page("issue#2", 'master')).to eq("http://ci.gitlab.org/projects/2/refs/master/commits/issue%232")}
+ it { expect(@service.build_page("2ab7834c", 'master')).to eq("/ci/projects/#{@ci_project.id}/refs/master/commits/2ab7834c")}
+ it { expect(@service.build_page("issue#2", 'master')).to eq("/ci/projects/#{@ci_project.id}/refs/master/commits/issue%232")}
end
describe "execute" do
@@ -80,8 +50,6 @@ describe GitlabCiService do
it "calls ci_yaml_file" do
service_hook = double
- expect(service_hook).to receive(:execute)
- expect(@service).to receive(:service_hook).and_return(service_hook)
expect(@service).to receive(:ci_yaml_file).with(push_sample_data[:checkout_sha])
@service.execute(push_sample_data)
@@ -91,7 +59,7 @@ describe GitlabCiService do
describe "Fork registration" do
before do
- @old_project = create(:empty_project)
+ @old_project = create(:ci_project).gl_project
@project = create(:empty_project)
@user = create(:user)
@@ -104,9 +72,9 @@ describe GitlabCiService do
)
end
- it "performs http reuquest to ci" do
- stub_request(:post, "http://ci.gitlab.org/api/v1/forks")
- @service.fork_registration(@project, @user.private_token)
+ it "creates fork on CI" do
+ expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
+ @service.fork_registration(@project, @user)
end
end
end
diff --git a/spec/requests/api/projects_spec.rb b/spec/requests/api/projects_spec.rb
index 5bd8206b890..3007a15b0b1 100644
--- a/spec/requests/api/projects_spec.rb
+++ b/spec/requests/api/projects_spec.rb
@@ -89,7 +89,7 @@ describe API::API, api: true do
it 'returns projects in the correct order when ci_enabled_first parameter is passed' do
[project, project2, project3].each{ |project| project.build_missing_services }
- project2.gitlab_ci_service.update(active: true, token: "token", project_url: "http://ci.example.com/projects/1")
+ project2.gitlab_ci_service.update(active: true, token: "token")
get api('/projects', user), { ci_enabled_first: 'true' }
expect(response.status).to eq(200)
expect(json_response).to be_an Array
diff --git a/spec/requests/api/services_spec.rb b/spec/requests/api/services_spec.rb
index fb3b235446f..9aa60826f21 100644
--- a/spec/requests/api/services_spec.rb
+++ b/spec/requests/api/services_spec.rb
@@ -17,9 +17,9 @@ describe API::API, api: true do
it "should return if required fields missing" do
attrs = service_attrs
-
+
required_attributes = service_attrs_list.select do |attr|
- service_klass.validators_on(attr).any? do |v|
+ service_klass.validators_on(attr).any? do |v|
v.class == ActiveRecord::Validations::PresenceValidator
end
end
diff --git a/spec/requests/ci/api/forks_spec.rb b/spec/requests/ci/api/forks_spec.rb
deleted file mode 100644
index 37fa1e82f25..00000000000
--- a/spec/requests/ci/api/forks_spec.rb
+++ /dev/null
@@ -1,59 +0,0 @@
-require 'spec_helper'
-
-describe Ci::API::API do
- include ApiHelpers
-
- let(:project) { FactoryGirl.create(:ci_project) }
- let(:private_token) { create(:user).private_token }
-
- let(:options) do
- {
- private_token: private_token,
- url: GitlabCi.config.gitlab_ci.url
- }
- end
-
- before do
- stub_gitlab_calls
- end
-
-
- describe "POST /forks" do
- let(:project_info) do
- {
- project_id: project.gitlab_id,
- project_token: project.token,
- data: {
- id: create(:empty_project).id,
- name_with_namespace: "Gitlab.org / Underscore",
- path_with_namespace: "gitlab-org/underscore",
- default_branch: "master",
- ssh_url_to_repo: "git@example.com:gitlab-org/underscore"
- }
- }
- end
-
- context "with valid info" do
- before do
- options.merge!(project_info)
- end
-
- it "should create a project with valid data" do
- post ci_api("/forks"), options
- expect(response.status).to eq(201)
- expect(json_response['name']).to eq("Gitlab.org / Underscore")
- end
- end
-
- context "with invalid project info" do
- before do
- options.merge!({})
- end
-
- it "should error with invalid data" do
- post ci_api("/forks"), options
- expect(response.status).to eq(400)
- end
- end
- end
-end
diff --git a/spec/services/ci/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb
index 64041b8d5a2..c0af515aa8f 100644
--- a/spec/services/ci/create_project_service_spec.rb
+++ b/spec/services/ci/create_project_service_spec.rb
@@ -7,7 +7,7 @@ describe Ci::CreateProjectService do
describe :execute do
context 'valid params' do
- subject { service.execute(current_user, project, 'http://localhost/projects/:project_id') }
+ subject { service.execute(current_user, project) }
it { is_expected.to be_kind_of(Ci::Project) }
it { is_expected.to be_persisted }
@@ -24,7 +24,7 @@ describe Ci::CreateProjectService do
FactoryGirl.create(:ci_project, shared_runners_enabled: true, public: true, allow_git_fetch: true)
end
- subject { service.execute(current_user, project, 'http://localhost/projects/:project_id', ci_origin_project) }
+ subject { service.execute(current_user, project, ci_origin_project) }
it "uses project as a template for settings and jobs" do
expect(subject.shared_runners_enabled).to be_truthy
diff --git a/spec/services/projects/fork_service_spec.rb b/spec/services/projects/fork_service_spec.rb
index 7c4bb74b77f..18ab333c1d1 100644
--- a/spec/services/projects/fork_service_spec.rb
+++ b/spec/services/projects/fork_service_spec.rb
@@ -44,10 +44,11 @@ describe Projects::ForkService do
context 'GitLab CI is enabled' do
it "calls fork registrator for CI" do
+ create(:ci_project, gl_project: @from_project)
@from_project.build_missing_services
@from_project.gitlab_ci_service.update_attributes(active: true)
- expect(ForkRegistrationWorker).to receive(:perform_async)
+ expect_any_instance_of(Ci::CreateProjectService).to receive(:execute)
fork_project(@from_project, @to_user)
end
diff --git a/spec/workers/fork_registration_worker_spec.rb b/spec/workers/fork_registration_worker_spec.rb
deleted file mode 100644
index cc6f574b29c..00000000000
--- a/spec/workers/fork_registration_worker_spec.rb
+++ /dev/null
@@ -1,10 +0,0 @@
-
-require 'spec_helper'
-
-describe ForkRegistrationWorker do
- context "as a resque worker" do
- it "reponds to #perform" do
- expect(ForkRegistrationWorker.new).to respond_to(:perform)
- end
- end
-end