summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/controllers/projects/compare_controller.rb10
-rw-r--r--app/mailers/notify.rb4
-rw-r--r--app/models/project_services/gitlab_ci_service.rb8
-rw-r--r--app/models/sent_notification.rb6
-rw-r--r--app/services/compare_service.rb5
-rw-r--r--app/views/admin/dashboard/index.html.haml2
-rw-r--r--app/views/projects/merge_requests/widget/_heading.html.haml3
-rw-r--r--app/views/projects/milestones/_form.html.haml2
-rw-r--r--app/views/projects/wikis/_form.html.haml2
-rw-r--r--app/views/shared/issuable/_form.html.haml2
-rw-r--r--app/workers/email_receiver_worker.rb2
-rw-r--r--config/gitlab.yml.example8
-rw-r--r--config/initializers/1_settings.rb4
-rw-r--r--db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb5
-rw-r--r--doc/README.md2
-rw-r--r--doc/incoming_email/README.md (renamed from doc/reply_by_email/README.md)48
-rw-r--r--doc/incoming_email/postfix.md (renamed from doc/reply_by_email/postfix.md)52
-rw-r--r--doc/migrate_ci_to_ce/README.md472
-rw-r--r--lib/ci/migrate/builds.rb2
-rw-r--r--lib/ci/migrate/manager.rb4
-rw-r--r--lib/gitlab/email/receiver.rb2
-rw-r--r--lib/gitlab/incoming_email.rb (renamed from lib/gitlab/reply_by_email.rb)20
-rw-r--r--lib/gitlab/markdown/relative_link_filter.rb40
-rw-r--r--lib/support/nginx/gitlab_ci12
-rw-r--r--lib/tasks/gitlab/check.rake18
-rw-r--r--spec/controllers/projects/compare_controller_spec.rb26
-rw-r--r--spec/lib/gitlab/email/receiver_spec.rb2
-rw-r--r--spec/lib/gitlab/incoming_email_spec.rb61
-rw-r--r--spec/lib/gitlab/markdown/relative_link_filter_spec.rb26
-rw-r--r--spec/lib/gitlab/reply_by_email_spec.rb86
-rw-r--r--spec/models/ci/variable_spec.rb3
-rw-r--r--spec/models/ci/web_hook_spec.rb3
-rw-r--r--spec/requests/ci/api/projects_spec.rb3
-rw-r--r--spec/services/ci/create_project_service_spec.rb3
-rw-r--r--spec/support/stub_configuration.rb4
-rw-r--r--spec/workers/email_receiver_worker_spec.rb4
36 files changed, 517 insertions, 439 deletions
diff --git a/app/controllers/projects/compare_controller.rb b/app/controllers/projects/compare_controller.rb
index d9b3adae95b..d15004f93a6 100644
--- a/app/controllers/projects/compare_controller.rb
+++ b/app/controllers/projects/compare_controller.rb
@@ -16,10 +16,12 @@ class Projects::CompareController < Projects::ApplicationController
compare_result = CompareService.new.
execute(@project, head_ref, @project, base_ref)
- @commits = compare_result.commits
- @diffs = compare_result.diffs
- @commit = @commits.last
- @line_notes = []
+ if compare_result
+ @commits = compare_result.commits
+ @diffs = compare_result.diffs
+ @commit = @commits.last
+ @line_notes = []
+ end
end
def create
diff --git a/app/mailers/notify.rb b/app/mailers/notify.rb
index f196ffd53f3..db2f9654e14 100644
--- a/app/mailers/notify.rb
+++ b/app/mailers/notify.rb
@@ -110,7 +110,7 @@ class Notify < BaseMailer
if reply_key
headers['X-GitLab-Reply-Key'] = reply_key
- address = Mail::Address.new(Gitlab::ReplyByEmail.reply_address(reply_key))
+ address = Mail::Address.new(Gitlab::IncomingEmail.reply_address(reply_key))
address.display_name = @project.name_with_namespace
headers['Reply-To'] = address
@@ -150,6 +150,6 @@ class Notify < BaseMailer
end
def reply_key
- @reply_key ||= Gitlab::ReplyByEmail.reply_key
+ @reply_key ||= SentNotification.reply_key
end
end
diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb
index 820dd3f567c..9e2b3bcd873 100644
--- a/app/models/project_services/gitlab_ci_service.rb
+++ b/app/models/project_services/gitlab_ci_service.rb
@@ -46,7 +46,9 @@ class GitlabCiService < CiService
end
ci_project = Ci::Project.find_by(gitlab_id: project.id)
- Ci::CreateCommitService.new.execute(ci_project, data)
+ if ci_project
+ Ci::CreateCommitService.new.execute(ci_project, data)
+ end
end
def get_ci_commit(sha, ref)
@@ -85,7 +87,9 @@ class GitlabCiService < CiService
end
def build_page(sha, ref)
- Ci::RoutesHelper.ci_project_ref_commits_path(project.gitlab_ci_project, ref, sha)
+ if project.gitlab_ci_project.present?
+ Ci::RoutesHelper.ci_project_ref_commits_path(project.gitlab_ci_project, ref, sha)
+ end
end
def title
diff --git a/app/models/sent_notification.rb b/app/models/sent_notification.rb
index 03425389dd3..3eed5c16e45 100644
--- a/app/models/sent_notification.rb
+++ b/app/models/sent_notification.rb
@@ -25,6 +25,12 @@ class SentNotification < ActiveRecord::Base
validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
class << self
+ def reply_key
+ return nil unless Gitlab::IncomingEmail.enabled?
+
+ SecureRandom.hex(16)
+ end
+
def for(reply_key)
find_by(reply_key: reply_key)
end
diff --git a/app/services/compare_service.rb b/app/services/compare_service.rb
index 70f642baaaa..bfe6a3dc4be 100644
--- a/app/services/compare_service.rb
+++ b/app/services/compare_service.rb
@@ -4,7 +4,10 @@ require 'securerandom'
# and return Gitlab::CompareResult object that responds to commits and diffs
class CompareService
def execute(source_project, source_branch, target_project, target_branch)
- source_sha = source_project.commit(source_branch).sha
+ source_commit = source_project.commit(source_branch)
+ return unless source_commit
+
+ source_sha = source_commit.sha
# If compare with other project we need to fetch ref first
unless target_project == source_project
diff --git a/app/views/admin/dashboard/index.html.haml b/app/views/admin/dashboard/index.html.haml
index 54191aadda6..8657d2c71fe 100644
--- a/app/views/admin/dashboard/index.html.haml
+++ b/app/views/admin/dashboard/index.html.haml
@@ -58,7 +58,7 @@
%p
Reply by email
%span.light.pull-right
- = boolean_to_icon Gitlab::ReplyByEmail.enabled?
+ = boolean_to_icon Gitlab::IncomingEmail.enabled?
.col-md-4
%h4
Components
diff --git a/app/views/projects/merge_requests/widget/_heading.html.haml b/app/views/projects/merge_requests/widget/_heading.html.haml
index 4d4e2f68f61..10640f746f0 100644
--- a/app/views/projects/merge_requests/widget/_heading.html.haml
+++ b/app/views/projects/merge_requests/widget/_heading.html.haml
@@ -10,7 +10,8 @@
%span CI build #{status}
for #{@merge_request.last_commit_short_sha}.
%span.ci-coverage
- = link_to "View build details", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
+ - if ci_build_details_path(@merge_request)
+ = link_to "View build details", ci_build_details_path(@merge_request), :"data-no-turbolink" => "data-no-turbolink"
.ci_widget
= icon("spinner spin")
diff --git a/app/views/projects/milestones/_form.html.haml b/app/views/projects/milestones/_form.html.haml
index b93462e5bdf..74e9668052d 100644
--- a/app/views/projects/milestones/_form.html.haml
+++ b/app/views/projects/milestones/_form.html.haml
@@ -21,7 +21,7 @@
.form-group.milestone-description
= f.label :description, "Description", class: "control-label"
.col-sm-10
- = render layout: 'projects/md_preview', locals: { preview_class: "wiki" } do
+ = render layout: 'projects/md_preview', locals: { preview_class: "md-preview" } do
= render 'projects/zen', f: f, attr: :description, classes: 'description form-control'
.hint
.pull-left Milestones are parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}.
diff --git a/app/views/projects/wikis/_form.html.haml b/app/views/projects/wikis/_form.html.haml
index 904600499ae..05d754adbe5 100644
--- a/app/views/projects/wikis/_form.html.haml
+++ b/app/views/projects/wikis/_form.html.haml
@@ -21,7 +21,7 @@
.form-group.wiki-content
= f.label :content, class: 'control-label'
.col-sm-10
- = render layout: 'projects/md_preview', locals: { preview_class: "wiki" } do
+ = render layout: 'projects/md_preview', locals: { preview_class: "md-preview" } do
= render 'projects/zen', f: f, attr: :content, classes: 'description form-control'
.col-sm-12.hint
.pull-left Wiki content is parsed with #{link_to "GitLab Flavored Markdown", help_page_path("markdown", "markdown"), target: '_blank'}
diff --git a/app/views/shared/issuable/_form.html.haml b/app/views/shared/issuable/_form.html.haml
index 1aa1e3c6c97..33ec726e93c 100644
--- a/app/views/shared/issuable/_form.html.haml
+++ b/app/views/shared/issuable/_form.html.haml
@@ -24,7 +24,7 @@
= f.label :description, 'Description', class: 'control-label'
.col-sm-10
- = render layout: 'projects/md_preview', locals: { preview_class: "wiki", referenced_users: true } do
+ = render layout: 'projects/md_preview', locals: { preview_class: "md-preview", referenced_users: true } do
= render 'projects/zen', f: f, attr: :description,
classes: 'description form-control'
.col-sm-12.hint
diff --git a/app/workers/email_receiver_worker.rb b/app/workers/email_receiver_worker.rb
index 8cfb96ef376..5a921a73fe9 100644
--- a/app/workers/email_receiver_worker.rb
+++ b/app/workers/email_receiver_worker.rb
@@ -4,7 +4,7 @@ class EmailReceiverWorker
sidekiq_options queue: :incoming_email
def perform(raw)
- return unless Gitlab::ReplyByEmail.enabled?
+ return unless Gitlab::IncomingEmail.enabled?
begin
Gitlab::Email::Receiver.new(raw).execute
diff --git a/config/gitlab.yml.example b/config/gitlab.yml.example
index 856e75dc829..15930fc9079 100644
--- a/config/gitlab.yml.example
+++ b/config/gitlab.yml.example
@@ -96,10 +96,10 @@ production: &base
## Reply by email
# Allow users to comment on issues and merge requests by replying to notification emails.
- # For documentation on how to set this up, see http://doc.gitlab.com/ce/reply_by_email/README.html
- reply_by_email:
+ # For documentation on how to set this up, see http://doc.gitlab.com/ce/incoming_email/README.html
+ incoming_email:
enabled: false
- address: "replies+%{reply_key}@gitlab.example.com"
+ address: "incoming+%{key}@gitlab.example.com"
## Gravatar
## For Libravatar see: http://doc.gitlab.com/ce/customization/libravatar.html
@@ -425,4 +425,4 @@ test:
sync_ssh_keys: false
staging:
- <<: *base \ No newline at end of file
+ <<: *base
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index ddc9bbf5dfd..48601b67335 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -187,8 +187,8 @@ Settings.gitlab_ci['builds_path'] = File.expand_path(Settings.gitlab_ci[
#
# Reply by email
#
-Settings['reply_by_email'] ||= Settingslogic.new({})
-Settings.reply_by_email['enabled'] = false if Settings.reply_by_email['enabled'].nil?
+Settings['incoming_email'] ||= Settingslogic.new({})
+Settings.incoming_email['enabled'] = false if Settings.incoming_email['enabled'].nil?
#
# Gravatar
diff --git a/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb b/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb
new file mode 100644
index 00000000000..0aad6fe5e6e
--- /dev/null
+++ b/db/migrate/20150918161719_remove_invalid_milestones_from_merge_requests.rb
@@ -0,0 +1,5 @@
+class RemoveInvalidMilestonesFromMergeRequests < ActiveRecord::Migration
+ def up
+ execute("UPDATE merge_requests SET milestone_id = NULL where milestone_id NOT IN (SELECT id FROM milestones)")
+ end
+end
diff --git a/doc/README.md b/doc/README.md
index f5f1f56b1e2..5f38086b8e3 100644
--- a/doc/README.md
+++ b/doc/README.md
@@ -46,7 +46,7 @@
- [System hooks](system_hooks/system_hooks.md) Notifications when users, projects and keys are changed.
- [Update](update/README.md) Update guides to upgrade your installation.
- [Welcome message](customization/welcome_message.md) Add a custom welcome message to the sign-in page.
-- [Reply by email](reply_by_email/README.md) Allow users to comment on issues and merge requests by replying to notification emails.
+- [Reply by email](incoming_email/README.md) Allow users to comment on issues and merge requests by replying to notification emails.
- [Migrate GitLab CI to CE/EE](migrate_ci_to_ce/README.md) Follow this guide to migrate your existing GitLab CI data to GitLab CE/EE.
### Administrator documentation
diff --git a/doc/reply_by_email/README.md b/doc/incoming_email/README.md
index e9187298d79..c94e25bd4cc 100644
--- a/doc/reply_by_email/README.md
+++ b/doc/incoming_email/README.md
@@ -12,24 +12,24 @@ To set up a basic Postfix mail server with IMAP access on Ubuntu, follow [these
## Set it up
-In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
+In this example, we'll use the Gmail address `gitlab-incoming@gmail.com`.
### Omnibus package installations
-1. Find the `reply_by_email` section in `/etc/gitlab/gitlab.rb`, enable the feature, enter the email address including a placeholder for the `reply_key` and fill in the details for your specific IMAP server and email account:
+1. Find the `incoming_email` section in `/etc/gitlab/gitlab.rb`, enable the feature, enter the email address including a placeholder for the `key` that references the item being replied to and fill in the details for your specific IMAP server and email account:
```ruby
- gitlab_rails['reply_by_email_enabled'] = true
- gitlab_rails['reply_by_email_address'] = "gitlab-replies+%{reply_key}@gmail.com"
- gitlab_rails['reply_by_email_host'] = "imap.gmail.com" # IMAP server host
- gitlab_rails['reply_by_email_port'] = 993 # IMAP server port
- gitlab_rails['reply_by_email_ssl'] = true # Whether the IMAP server uses SSL
- gitlab_rails['reply_by_email_email'] = "gitlab-replies@gmail.com" # Email account username. Usually the full email address.
- gitlab_rails['reply_by_email_password'] = "password" # Email account password
- gitlab_rails['reply_by_email_mailbox_name'] = "inbox" # The name of the mailbox where incoming mail will end up. Usually "inbox".
+ gitlab_rails['incoming_email_enabled'] = true
+ gitlab_rails['incoming_email_address'] = "gitlab-incoming+%{key}@gmail.com"
+ gitlab_rails['incoming_email_host'] = "imap.gmail.com" # IMAP server host
+ gitlab_rails['incoming_email_port'] = 993 # IMAP server port
+ gitlab_rails['incoming_email_ssl'] = true # Whether the IMAP server uses SSL
+ gitlab_rails['incoming_email_email'] = "gitlab-incoming@gmail.com" # Email account username. Usually the full email address.
+ gitlab_rails['incoming_email_password'] = "password" # Email account password
+ gitlab_rails['incoming_email_mailbox_name'] = "inbox" # The name of the mailbox where incoming mail will end up. Usually "inbox".
```
- As mentioned, the part after `+` in the address is ignored, and any email sent here will end up in the mailbox for `gitlab-replies@gmail.com`.
+ As mentioned, the part after `+` in the address is ignored, and any email sent here will end up in the mailbox for `gitlab-incoming@gmail.com`.
1. Reconfigure GitLab for the changes to take effect:
@@ -40,7 +40,7 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
1. Verify that everything is configured correctly:
```sh
- sudo gitlab-rake gitlab:reply_by_email:check
+ sudo gitlab-rake gitlab:incoming_email:check
```
1. Reply by email should now be working.
@@ -53,19 +53,19 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
cd /home/git/gitlab
```
-1. Find the `reply_by_email` section in `config/gitlab.yml`, enable the feature and enter the email address including a placeholder for the `reply_key`:
+1. Find the `incoming_email` section in `config/gitlab.yml`, enable the feature and enter the email address including a placeholder for the `key` that references the item being replied to:
```sh
sudo editor config/gitlab.yml
```
```yaml
- reply_by_email:
+ incoming_email:
enabled: true
- address: "gitlab-replies+%{reply_key}@gmail.com"
+ address: "gitlab-incoming+%{key}@gmail.com"
```
- As mentioned, the part after `+` in the address is ignored, and any email sent here will end up in the mailbox for `gitlab-replies@gmail.com`.
+ As mentioned, the part after `+` in the address is ignored, and any email sent here will end up in the mailbox for `gitlab-incoming@gmail.com`.
2. Copy `config/mail_room.yml.example` to `config/mail_room.yml`:
@@ -89,7 +89,7 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
# Whether the IMAP server uses SSL
:ssl: true
# Email account username. Usually the full email address.
- :email: "gitlab-replies@gmail.com"
+ :email: "gitlab-incoming@gmail.com"
# Email account password
:password: "[REDACTED]"
# The name of the mailbox where incoming mail will end up. Usually "inbox".
@@ -125,7 +125,7 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
7. Verify that everything is configured correctly:
```sh
- sudo -u git -H bundle exec rake gitlab:reply_by_email:check RAILS_ENV=production
+ sudo -u git -H bundle exec rake gitlab:incoming_email:check RAILS_ENV=production
```
8. Reply by email should now be working.
@@ -134,15 +134,15 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
1. Go to the GitLab installation directory.
-1. Find the `reply_by_email` section in `config/gitlab.yml`, enable the feature and enter the email address including a placeholder for the `reply_key`:
+1. Find the `incoming_email` section in `config/gitlab.yml`, enable the feature and enter the email address including a placeholder for the `key` that references the item being replied to:
```yaml
- reply_by_email:
+ incoming_email:
enabled: true
- address: "gitlab-replies+%{reply_key}@gmail.com"
+ address: "gitlab-incoming+%{key}@gmail.com"
```
- As mentioned, the part after `+` is ignored, and this will end up in the mailbox for `gitlab-replies@gmail.com`.
+ As mentioned, the part after `+` is ignored, and this will end up in the mailbox for `gitlab-incoming@gmail.com`.
2. Copy `config/mail_room.yml.example` to `config/mail_room.yml`:
@@ -162,7 +162,7 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
# Whether the IMAP server uses SSL
:ssl: true
# Email account username. Usually the full email address.
- :email: "gitlab-replies@gmail.com"
+ :email: "gitlab-incoming@gmail.com"
# Email account password
:password: "[REDACTED]"
# The name of the mailbox where incoming mail will end up. Usually "inbox".
@@ -197,7 +197,7 @@ In this example, we'll use the Gmail address `gitlab-replies@gmail.com`.
7. Verify that everything is configured correctly:
```sh
- bundle exec rake gitlab:reply_by_email:check RAILS_ENV=development
+ bundle exec rake gitlab:incoming_email:check RAILS_ENV=development
```
8. Reply by email should now be working.
diff --git a/doc/reply_by_email/postfix.md b/doc/incoming_email/postfix.md
index c0ac59bb922..18bf3db1744 100644
--- a/doc/reply_by_email/postfix.md
+++ b/doc/incoming_email/postfix.md
@@ -2,7 +2,7 @@
This document will take you through the steps of setting up a basic Postfix mail server with IMAP authentication on Ubuntu, to be used with Reply by email.
-The instructions make the assumption that you will be using the email address `replies@gitlab.example.com`, that is, username `replies` on host `gitlab.example.com`. Don't forget to change it to your actual host when executing the example code snippets.
+The instructions make the assumption that you will be using the email address `incoming@gitlab.example.com`, that is, username `incoming` on host `gitlab.example.com`. Don't forget to change it to your actual host when executing the example code snippets.
## Configure your server firewall
@@ -27,16 +27,16 @@ The instructions make the assumption that you will be using the email address `r
## Create user
-1. Create a user for replies.
+1. Create a user for incoming email.
```sh
- sudo useradd -m -s /bin/bash replies
+ sudo useradd -m -s /bin/bash incoming
```
1. Set a password for this user.
```sh
- sudo passwd replies
+ sudo passwd incoming
```
Be sure not to forget this, you'll need it later.
@@ -70,12 +70,12 @@ The instructions make the assumption that you will be using the email address `r
sudo postfix start
```
-1. Send the new `replies` user a dummy email to test SMTP, by entering the following into the SMTP prompt:
+1. Send the new `incoming` user a dummy email to test SMTP, by entering the following into the SMTP prompt:
```
ehlo localhost
mail from: root@localhost
- rcpt to: replies@localhost
+ rcpt to: incoming@localhost
data
Subject: Re: Some issue
@@ -86,17 +86,17 @@ The instructions make the assumption that you will be using the email address `r
(Note: The `.` is a literal period on its own line)
-1. Check if the `replies` user received the email:
+1. Check if the `incoming` user received the email:
```sh
- su - replies
+ su - incoming
mail
```
You should see output like this:
```
- "/var/mail/replies": 1 message 1 unread
+ "/var/mail/incoming": 1 message 1 unread
>U 1 root@localhost 59/2842 Re: Some issue
```
@@ -106,7 +106,7 @@ The instructions make the assumption that you will be using the email address `r
q
```
-1. Log out of the `replies` account and go back to being `root`:
+1. Log out of the `incoming` account and go back to being `root`:
```sh
logout
@@ -131,18 +131,18 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
1. Test the new setup:
1. Follow steps 1 and 2 of _[Test the out-of-the-box setup](#test-the-out-of-the-box-setup)_.
- 2. Check if the `replies` user received the email:
+ 2. Check if the `incoming` user received the email:
```sh
- su - replies
- MAIL=/home/replies/Maildir
+ su - incoming
+ MAIL=/home/incoming/Maildir
mail
```
You should see output like this:
```
- "/home/replies/Maildir": 1 message 1 unread
+ "/home/incoming/Maildir": 1 message 1 unread
>U 1 root@localhost 59/2842 Re: Some issue
```
@@ -152,7 +152,7 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
q
```
-1. Log out of the `replies` account and go back to being `root`:
+1. Log out of the `incoming` account and go back to being `root`:
```sh
logout
@@ -221,12 +221,12 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
If you get a `Connection refused` error instead, make sure your firewall is setup to allow inbound traffic on port 25.
- 1. Send the `replies` user a dummy email to test SMTP, by entering the following into the SMTP prompt:
+ 1. Send the `incoming` user a dummy email to test SMTP, by entering the following into the SMTP prompt:
```
ehlo gitlab.example.com
mail from: root@gitlab.example.com
- rcpt to: replies@gitlab.example.com
+ rcpt to: incoming@gitlab.example.com
data
Subject: Re: Some issue
@@ -237,18 +237,18 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
(Note: The `.` is a literal period on its own line)
- 1. Check if the `replies` user received the email:
+ 1. Check if the `incoming` user received the email:
```sh
- su - replies
- MAIL=/home/replies/Maildir
+ su - incoming
+ MAIL=/home/incoming/Maildir
mail
```
You should see output like this:
```
- "/home/replies/Maildir": 1 message 1 unread
+ "/home/incoming/Maildir": 1 message 1 unread
>U 1 root@gitlab.example.com 59/2842 Re: Some issue
```
@@ -258,7 +258,7 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
q
```
- 1. Log out of the `replies` account and go back to being `root`:
+ 1. Log out of the `incoming` account and go back to being `root`:
```sh
logout
@@ -281,13 +281,13 @@ Courier, which we will install later to add IMAP authentication, requires mailbo
- OK [CAPABILITY IMAP4rev1 UIDPLUS CHILDREN NAMESPACE THREAD=ORDEREDSUBJECT THREAD=REFERENCES SORT QUOTA IDLE ACL ACL2=UNION] Courier-IMAP ready. Copyright 1998-2011 Double Precision, Inc. See COPYING for distribution information.
```
- 1. Sign in as the `replies` user to test IMAP, by entering the following into the IMAP prompt:
+ 1. Sign in as the `incoming` user to test IMAP, by entering the following into the IMAP prompt:
```
- a login replies PASSWORD
+ a login incoming PASSWORD
```
- Replace PASSWORD with the password you set on the `replies` user earlier.
+ Replace PASSWORD with the password you set on the `incoming` user earlier.
You should see output like this:
@@ -307,4 +307,4 @@ If all the tests were successful, Postfix is all set up and ready to receive ema
---------
-_This document was adapted from https://help.ubuntu.com/community/PostfixBasicSetupHowto, by contributors to the Ubuntu documentation wiki._ \ No newline at end of file
+_This document was adapted from https://help.ubuntu.com/community/PostfixBasicSetupHowto, by contributors to the Ubuntu documentation wiki._
diff --git a/doc/migrate_ci_to_ce/README.md b/doc/migrate_ci_to_ce/README.md
index 1e45f29dbb2..1f050e2def2 100644
--- a/doc/migrate_ci_to_ce/README.md
+++ b/doc/migrate_ci_to_ce/README.md
@@ -1,280 +1,312 @@
-## Migrate GitLab CI to GitLab CE/EE
+## Migrate GitLab CI to GitLab CE or EE
-## Notice
+Beginning with version 8.0 of GitLab Community Edition (CE) and Enterprise
+Edition (EE), GitLab CI is no longer its own application, but is instead built
+into the CE and EE applications.
-**You need to have working GitLab CI 7.14 to perform migration.
-The older versions are not supported and will most likely break migration procedure.**
+This guide will detail the process of migrating your CI installation and data
+into your GitLab CE or EE installation.
-This migration can't be done online and takes significant amount of time.
-Make sure to plan it ahead.
+### Before we begin
-If you are running older version please follow the upgrade guide first:
-https://gitlab.com/gitlab-org/gitlab-ci/blob/master/doc/update/7.13-to-7.14.md
+**You need to have a working installation of GitLab CI version 8.0 to perform
+this migration. The older versions are not supported and will most likely break
+this migration procedure.**
-The migration is divided into a two parts:
-1. **[CI]** You will be making a changes to GitLab CI instance.
-1. **[CE]** You will be making a changes to GitLab CE/EE instance.
+This migration cannot be performed online and takes a significant amount of
+time. Make sure to plan ahead.
-### 1. Stop CI server [CI]
+If you are running a version of GitLab CI prior to 8.0 please follow the
+appropriate [update guide](https://gitlab.com/gitlab-org/gitlab-ci/tree/master/doc/update/)
+before proceeding.
- sudo service gitlab_ci stop
-
-### 2. Backup [CI]
+The migration is divided into four parts and covers both manual and Omnibus
+installations:
-**The migration procedure is database breaking.
-You need to create backup if you still want to access GitLab CI in case of failure.**
+1. [GitLab CI](#part-i-gitlab-ci)
+1. [Gitlab CE (or EE)](#part-ii-gitlab-ce-or-ee)
+1. [Nginx configuration](#part-iii-nginx-configuration)
+1. [Finishing Up](#part-iv-finishing-up)
-```bash
-cd /home/gitlab_ci/gitlab-ci
-sudo -u gitlab_ci -H bundle exec backup:create RAILS_ENV=production
-```
+### Part I: GitLab CI
-### 3. Prepare GitLab CI database to migration [CI]
-
-Copy and paste the command in terminal to rename all tables.
-This also breaks your database structure disallowing you to use it anymore.
-
- cat <<EOF | bundle exec rails dbconsole production
- ALTER TABLE application_settings RENAME TO ci_application_settings;
- ALTER TABLE builds RENAME TO ci_builds;
- ALTER TABLE commits RENAME TO ci_commits;
- ALTER TABLE events RENAME TO ci_events;
- ALTER TABLE jobs RENAME TO ci_jobs;
- ALTER TABLE projects RENAME TO ci_projects;
- ALTER TABLE runner_projects RENAME TO ci_runner_projects;
- ALTER TABLE runners RENAME TO ci_runners;
- ALTER TABLE services RENAME TO ci_services;
- ALTER TABLE tags RENAME TO ci_tags;
- ALTER TABLE taggings RENAME TO ci_taggings;
- ALTER TABLE trigger_requests RENAME TO ci_trigger_requests;
- ALTER TABLE triggers RENAME TO ci_triggers;
- ALTER TABLE variables RENAME TO ci_variables;
- ALTER TABLE web_hooks RENAME TO ci_web_hooks;
- EOF
-
-### 4. Remove CI cronjob
+#### 1. Stop GitLab CI
-```
-cd /home/gitlab_ci/gitlab-ci
-sudo -u gitlab_ci -H bundle exec whenever --clear-crontab
-```
+ # Manual installation
+ sudo service gitlab_ci stop
-### 5. Dump GitLab CI database [CI]
+ # Omnibus installation
+ sudo gitlab-ctl stop ci-unicorn ci-sidekiq
-First check used database and credentials on GitLab CI and GitLab CE/EE:
+#### 2. Create a backup
-1. To check it on GitLab CI:
+The migration procedure modifies the structure of the CI database. If something
+goes wrong, you will not be able to revert to a previous version without a
+backup.
- cat /home/gitlab_ci/gitlab-ci/config/database.yml
-
-1. To check it on GitLab CE/EE:
+If your GitLab CI installation uses **MySQL** and your GitLab CE (or EE)
+installation uses **PostgreSQL** you'll need to convert the CI database by
+setting a `MYSQL_TO_POSTGRESQL` flag.
+
+If you use the Omnibus package you most likely use **PostgreSQL** on both GitLab
+CE (or EE) and CI.
+
+You can check which database each install is using by viewing their
+database configuration files:
+ cat /home/gitlab_ci/gitlab-ci/config/database.yml
cat /home/git/gitlab/config/database.yml
-Please first check the database engine used for GitLab CI and GitLab CE/EE.
-
-1. If your GitLab CI uses **mysql2** and GitLab CE/EE uses it too.
-Please follow **Dump MySQL** guide.
-
-1. If your GitLab CI uses **postgres** and GitLab CE/EE uses **postgres**.
-Please follow **Dump PostgreSQL** guide.
-
-1. If your GitLab CI uses **mysql2** and GitLab CE/EE uses **postgres**.
-Please follow **Dump MySQL and migrate to PostgreSQL** guide.
-
-**Remember credentials stored for accessing GitLab CI.
-You will need to put these credentials into commands executed below.**
-
- $ cat config/database.yml [10:06:55]
- #
- # PRODUCTION
- #
- production:
- adapter: postgresql or mysql2
- encoding: utf8
- reconnect: false
- database: GITLAB_CI_DATABASE
- pool: 5
- username: DB_USERNAME
- password: DB_PASSWORD
- host: DB_HOSTNAME
- port: DB_PORT
- # socket: /tmp/mysql.sock
-
-#### a. Dump MySQL
-
- mysqldump --default-character-set=utf8 --complete-insert --no-create-info \
- --host=DB_USERNAME --port=DB_PORT --user=DB_HOSTNAME -p
- GITLAB_CI_DATABASE \
- ci_application_settings ci_builds ci_commits ci_events ci_jobs ci_projects \
- ci_runner_projects ci_runners ci_services ci_tags ci_taggings ci_trigger_requests \
- ci_triggers ci_variables ci_web_hooks > gitlab_ci.sql
-
-#### b. Dump PostgreSQL
-
- pg_dump -h DB_HOSTNAME -U DB_USERNAME -p DB_PORT --data-only GITLAB_CI_DATABASE -t "ci_*" > gitlab_ci.sql
-
-#### c. Dump MySQL and migrate to PostgreSQL
-
- # Dump existing MySQL database first
- mysqldump --default-character-set=utf8 --compatible=postgresql --complete-insert \
- --host=DB_USERNAME --port=DB_PORT --user=DB_HOSTNAME -p
- GITLAB_CI_DATABASE \
- ci_application_settings ci_builds ci_commits ci_events ci_jobs ci_projects \
- ci_runner_projects ci_runners ci_services ci_tags ci_taggings ci_trigger_requests \
- ci_triggers ci_variables ci_web_hooks > gitlab_ci.sql.tmp
-
- # Convert database to be compatible with PostgreSQL
- git clone https://github.com/gitlabhq/mysql-postgresql-converter.git -b gitlab
- python mysql-postgresql-converter/db_converter.py gitlab_ci.sql.tmp gitlab_ci.sql.tmp2
- ed -s gitlab_ci.sql.tmp2 < mysql-postgresql-converter/move_drop_indexes.ed
-
- # Filter to only include INSERT statements
- grep "^\(START\|SET\|INSERT\|COMMIT\)" gitlab_ci.sql.tmp2 > gitlab_ci.sql
-
-### 6. Make sure that your GitLab CE/EE is 8.0 [CE]
-
-Please verify that you use GitLab CE/EE 8.0.
-If not, please follow the update guide: https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.14-to-8.0.md
-
-### 7. Stop GitLab CE/EE [CE]
-
-Before you can migrate data you need to stop GitLab CE/EE first.
+- If both applications use the same database `adapter`, create the backup with
+ this command:
+
+ # Manual installation
+ cd /home/gitlab_ci/gitlab-ci
+ sudo -u gitlab_ci -H bundle exec rake backup:create RAILS_ENV=production
+
+ # Omnibus installation
+ sudo gitlab-ci-rake backup:create
+
+- If CI uses MySQL, and CE (or EE) uses PostgreSQL, create the backup with this
+ command (note the `MYSQL_TO_POSTGRESQL` flag):
+
+ # Manual installation
+ cd /home/gitlab_ci/gitlab-ci
+ sudo -u gitlab_ci -H bundle exec rake backup:create RAILS_ENV=production MYSQL_TO_POSTGRESQL=1
+
+ # Omnibus installation
+ sudo gitlab-ci-rake backup:create MYSQL_TO_POSTGRESQL=1
+
+#### 3. Remove cronjob
+
+**Note:** This step is only required for **manual installations**. Omnibus users
+can [skip to the next step](#part-ii-gitlab-ce-or-ee).
+ # Manual installation
+ cd /home/gitlab_ci/gitlab-ci
+ sudo -u gitlab_ci -H bundle exec whenever --clear-crontab
+
+### Part II: GitLab CE (or EE)
+
+#### 1. Ensure GitLab is updated
+
+Your GitLab CE or EE installation **must be version 8.0**. If it's not, follow
+the [update guide](https://gitlab.com/gitlab-org/gitlab-ce/blob/master/doc/update/7.14-to-8.0.md)
+before proceeding.
+
+If you use the Omnibus packages simply run `apt-get upgrade` to install the
+latest version.
+
+#### 2. Prevent CI usage during the migration process
+
+As an administrator, go to **Admin Area** -> **Settings**, and under **Continuous
+Integration** uncheck **Disable to prevent CI usage until rake ci:migrate is run
+(8.0 only)**.
+
+This will disable the CI integration and prevent users from creating CI projects
+until the migration process is completed.
+
+#### 3. Stop GitLab
+
+Before you can migrate data you need to stop the GitLab service first:
+
+ # Manual installation
sudo service gitlab stop
-
-### 8. Backup GitLab CE/EE [CE]
-This migration poses a **significant risk** of breaking your GitLab CE/EE.
-**You should create the GitLab CI/EE backup before doing it.**
+ # Omnibus installation
+ sudo gitlab-ctl stop unicorn sidekiq
+
+#### 4. Create a backup
+
+This migration poses a **significant risk** of breaking your GitLab
+installation. Create a backup before proceeding:
+ # Manual installation
cd /home/git/gitlab
sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
-### 9. Copy secret tokens [CE]
+ # Omnibus installation
+ sudo gitlab-rake gitlab:backup:create
+
+It's possible to speed up backup creation by skipping repositories and uploads:
+
+ # Manual installation
+ cd /home/git/gitlab
+ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production SKIP=repositories,uploads
+
+ # Omnibus installation
+ sudo gitlab-rake gitlab:backup:create SKIP=repositories,uploads
+
+#### 5. Copy secret tokens from CI
The `secrets.yml` file stores encryption keys for secure variables.
-You need to copy the content of `config/secrets.yml` to the same file in GitLab CE.
+- **Manual installations** need to copy the contents of GitLab CI's
+ `config/secrets.yml` file to the same file in GitLab CE:
+ ```bash
+ # Manual installation
sudo cp /home/gitlab_ci/gitlab-ci/config/secrets.yml /home/git/gitlab/config/secrets.yml
sudo chown git:git /home/git/gitlab/config/secrets.yml
sudo chown 0600 /home/git/gitlab/config/secrets.yml
-
-### 10. New configuration options for `gitlab.yml` [CE]
+ ```
+
+- **Omnibus installations** where GitLab CI and CE (or EE) are on the same
+ server don't need to do anything further, because the secrets are stored in
+ `/etc/gitlab/gitlab-secrets.json`.
+
+- **Omnibus installations** where GitLab CI is on a different server than CE (or
+ EE) will need to:
+ 1. On the CI server, copy the `db_key_base` value from
+ `/etc/gitlab/gitlab-secrets.json`
+ 1. On the CE (or EE) server, add `gitlab_ci['db_key_base'] =
+ "VALUE_FROM_ABOVE"` to the `/etc/gitlab/gitlab.rb` file and run `sudo
+ gitlab-ctl reconfigure`
+
+#### 6. New configuration options for `gitlab.yml`
+
+**Note:** This step is only required for **manual installations**. Omnibus users
+can [skip to the next step](#7-copy-backup-from-gitlab-ci).
-There are new configuration options available for [`gitlab.yml`](config/gitlab.yml.example).
-View them with the command below and apply them manually to your current `gitlab.yml`:
+There are new configuration options available for `gitlab.yml`. View them with
+the command below and apply them manually to your current `gitlab.yml`:
-```sh
-git diff origin/7-14-stable:config/gitlab.yml.example origin/8-0-stable:config/gitlab.yml.example
+ git diff origin/7-14-stable:config/gitlab.yml.example origin/8-0-stable:config/gitlab.yml.example
+
+The new options include configuration settings for GitLab CI.
+
+#### 7. Copy backup from GitLab CI
+
+```bash
+# Manual installation
+sudo cp -v /home/gitlab_ci/gitlab-ci/tmp/backups/*_gitlab_ci_backup.tar /home/git/gitlab/tmp/backups
+sudo chown git:git /home/git/gitlab/tmp/backups/*_gitlab_ci_backup.tar
+
+# Omnibus installation
+sudo cp -v /var/opt/gitlab/ci-backups/*_gitlab_ci_backup.tar /var/opt/gitlab/backups/
+sudo chown git:git /var/opt/gitlab/backups/*_gitlab_ci_backup.tar
```
-The new options include configuration of GitLab CI that are now being part of GitLab CE and EE.
+If moving across the servers you can use `scp`.
+However, this requires you to provide an authorized key or password to login to
+the GitLab CE (or EE) server from the CI server. You can try to use ssh-agent
+from your local machine to have that: login to your GitLab CI server using
+`ssh -A`.
-### 11. Copy build logs [CE]
+```bash
+# Manual installation
+scp /home/gitlab_ci/gitlab-ci/tmp/backups/*_gitlab_ci_backup.tar root@gitlab.example.com:/home/git/gitlab/tmp/backup
-You need to copy the contents of `builds/` to the same directory in GitLab CE/EE.
+# Omnibus installation
+scp /var/opt/gitlab/ci-backups/*_gitlab_ci_backup.tar root@gitlab.example.com:/var/opt/gitlab/backups/
+```
- sudo rsync -av /home/gitlab_ci/gitlab-ci/builds /home/git/gitlab/builds
- sudo chown -R git:git /home/git/gitlab/builds
+#### 8. Import GitLab CI backup
-The build traces are usually quite big so it will take a significant amount of time.
+Now you'll import the GitLab CI database dump that you created earlier into the
+GitLab CE or EE database:
-### 12. Import GitLab CI database [CE]
+ # Manual installation
+ sudo -u git -H bundle exec rake ci:migrate RAILS_ENV=production
-The one of the last steps is to import existing GitLab CI database.
+ # Omnibus installation
+ sudo gitlab-rake ci:migrate
- sudo mv /home/gitlab_ci/gitlab-ci/gitlab_ci.sql /home/git/gitlab/gitlab_ci.sql
- sudo chown git:git /home/git/gitlab/gitlab_ci.sql
- sudo -u git -H bundle exec rake ci:migrate CI_DUMP=/home/git/gitlab/gitlab_ci.sql RAILS_ENV=production
+This task will take some time.
-The task does:
-1. Delete data from all existing CI tables
-1. Import database data
-1. Fix database auto increments
-1. Fix tags assigned to Builds and Runners
-1. Fix services used by CI
+This migration task automatically re-enables the CI setting that you
+[disabled earlier](#2-prevent-ci-usage-during-the-migration-process).
-### 13. Start GitLab [CE]
+#### 9. Start GitLab
-You can start GitLab CI/EE now and see if everything is working.
+You can start GitLab CE (or EE) now and see if everything is working:
+ # Manual installation
sudo service gitlab start
-### 14. Update nginx [CI]
-
-Now get back to GitLab CI and update **Nginx** configuration in order to:
-1. Have all existing runners able to communicate with a migrated GitLab CI.
-1. Have GitLab able send build triggers to CI address specified in Project's settings -> Services -> GitLab CI.
-
-You need to edit `/etc/nginx/sites-available/gitlab_ci` and paste:
-
- # GITLAB CI
- server {
- listen 80 default_server; # e.g., listen 192.168.1.1:80;
- server_name YOUR_CI_SERVER_FQDN; # e.g., server_name source.example.com;
-
- access_log /var/log/nginx/gitlab_ci_access.log;
- error_log /var/log/nginx/gitlab_ci_error.log;
-
- # expose API to fix runners
- location /api {
- proxy_read_timeout 300;
- proxy_connect_timeout 300;
- proxy_redirect off;
- proxy_set_header X-Real-IP $remote_addr;
-
- # You need to specify your DNS servers that are able to resolve YOUR_GITLAB_SERVER_FQDN
- resolver 8.8.8.8 8.8.4.4;
- proxy_pass $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
- }
-
- # expose build endpoint to allow trigger builds
- location ~ ^/projects/\d+/build$ {
- proxy_read_timeout 300;
- proxy_connect_timeout 300;
- proxy_redirect off;
- proxy_set_header X-Real-IP $remote_addr;
-
- # You need to specify your DNS servers that are able to resolve YOUR_GITLAB_SERVER_FQDN
- resolver 8.8.8.8 8.8.4.4;
- proxy_pass $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
- }
-
- # redirect all other CI requests
- location / {
- return 301 $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
- }
-
- # adjust this to match the largest build log your runners might submit,
- # set to 0 to disable limit
- client_max_body_size 10m;
- }
-
-Make sure to fill the blanks to match your setup:
-1. **YOUR_CI_SERVER_FQDN**: The existing public facing address of GitLab CI, eg. ci.gitlab.com.
-1. **YOUR_GITLAB_SERVER_FQDN**: The public facing address of GitLab CE/EE, eg. gitlab.com.
-
-**Make sure to not remove the `/ci$request_uri`. This is required to properly forward the requests.**
-
-You should also make sure that you can do:
+ # Omnibus installation
+ sudo gitlab-ctl restart unicorn sidekiq
+
+### Part III: Nginx configuration
+
+This section is only required for **manual installations**. Omnibus users can
+[skip to the final step](#part-iv-finishing-up).
+
+#### 1. Update Nginx configuration
+
+To ensure that your existing CI runners are able to communicate with the
+migrated installation, and that existing build triggers still work, you'll need
+to update your Nginx configuration to redirect requests for the old locations to
+the new ones.
+
+Edit `/etc/nginx/sites-available/gitlab_ci` and paste:
+
+```nginx
+# GITLAB CI
+server {
+ listen 80 default_server; # e.g., listen 192.168.1.1:80;
+ server_name YOUR_CI_SERVER_FQDN; # e.g., server_name source.example.com;
+
+ access_log /var/log/nginx/gitlab_ci_access.log;
+ error_log /var/log/nginx/gitlab_ci_error.log;
+
+ # expose API to fix runners
+ location /api {
+ proxy_read_timeout 300;
+ proxy_connect_timeout 300;
+ proxy_redirect off;
+ proxy_set_header X-Real-IP $remote_addr;
+
+ # You need to specify your DNS servers that are able to resolve YOUR_GITLAB_SERVER_FQDN
+ resolver 8.8.8.8 8.8.4.4;
+ proxy_pass $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
+ }
+
+ # redirect all other CI requests
+ location / {
+ return 301 $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
+ }
+
+ # adjust this to match the largest build log your runners might submit,
+ # set to 0 to disable limit
+ client_max_body_size 10m;
+}
+```
+
+Make sure you substitute these placeholder values with your real ones:
+
+1. `YOUR_CI_SERVER_FQDN`: The existing public-facing address of your GitLab CI
+ install (e.g., `ci.gitlab.com`).
+1. `YOUR_GITLAB_SERVER_FQDN`: The current public-facing address of your GitLab
+ CE (or EE) install (e.g., `gitlab.com`).
+
+**Make sure not to remove the `/ci$request_uri` part. This is required to
+properly forward the requests.**
+
+You should also make sure that you can:
+
1. `curl https://YOUR_GITLAB_SERVER_FQDN/` from your previous GitLab CI server.
-1. `curl https://YOUR_CI_SERVER_FQDN/` from your GitLab CE/EE server.
+1. `curl https://YOUR_CI_SERVER_FQDN/` from your GitLab CE (or EE) server.
-## Check your configuration
+#### 2. Check Nginx configuration
sudo nginx -t
-## Restart nginx
+#### 3. Restart Nginx
sudo /etc/init.d/nginx restart
-### 15. Done!
+### Part IV: Finishing Up
-If everything went OK you should be able to access all your GitLab CI data by pointing your browser to:
-https://gitlab.example.com/ci/.
-
-The GitLab CI should also work when using the previous address, redirecting you to the GitLab CE/EE.
+If everything went well you should be able to access your migrated CI install by
+visiting `https://gitlab.example.com/ci/`. If you visit the old GitLab CI
+address, you should be redirected to the new one.
**Enjoy!**
+
+### Troubleshooting
+
+#### Restore from backup
+
+If something went wrong and you need to restore a backup, consult the [Backup
+restoration](../raketasks/backup_restore.md) guide.
diff --git a/lib/ci/migrate/builds.rb b/lib/ci/migrate/builds.rb
index fdc143cfad5..c4f62e55295 100644
--- a/lib/ci/migrate/builds.rb
+++ b/lib/ci/migrate/builds.rb
@@ -13,7 +13,7 @@ module Ci
backup_existing_builds_dir
FileUtils.mkdir_p(app_builds_dir, mode: 0700)
- unless system('tar', '-C', app_builds_dir, '-zxvf', backup_builds_tarball)
+ unless system('tar', '-C', app_builds_dir, '-zxf', backup_builds_tarball)
abort 'Restore failed'.red
end
end
diff --git a/lib/ci/migrate/manager.rb b/lib/ci/migrate/manager.rb
index 4205809368d..e5e4fb784eb 100644
--- a/lib/ci/migrate/manager.rb
+++ b/lib/ci/migrate/manager.rb
@@ -1,6 +1,8 @@
module Ci
module Migrate
class Manager
+ CI_IMPORT_PREFIX = '8.0' # Only allow imports from CI 8.0.x
+
def cleanup
$progress.print "Deleting tmp directories ... "
@@ -48,7 +50,7 @@ module Ci
ENV["VERSION"] = "#{settings[:db_version]}" if settings[:db_version].to_i > 0
# restoring mismatching backups can lead to unexpected problems
- if settings[:gitlab_version] != GitlabCi::VERSION
+ if !settings[:gitlab_version].start_with?(CI_IMPORT_PREFIX)
puts "GitLab CI version mismatch:".red
puts " Your current GitLab CI version (#{GitlabCi::VERSION}) differs from the GitLab CI (#{settings[:gitlab_version]}) version in the backup!".red
exit 1
diff --git a/lib/gitlab/email/receiver.rb b/lib/gitlab/email/receiver.rb
index 341b557858f..2b252b32887 100644
--- a/lib/gitlab/email/receiver.rb
+++ b/lib/gitlab/email/receiver.rb
@@ -65,7 +65,7 @@ module Gitlab
def reply_key
reply_key = nil
message.to.each do |address|
- reply_key = Gitlab::ReplyByEmail.reply_key_from_address(address)
+ reply_key = Gitlab::IncomingEmail.key_from_address(address)
break if reply_key
end
diff --git a/lib/gitlab/reply_by_email.rb b/lib/gitlab/incoming_email.rb
index c3fe6778f06..856ccc71084 100644
--- a/lib/gitlab/reply_by_email.rb
+++ b/lib/gitlab/incoming_email.rb
@@ -1,5 +1,5 @@
module Gitlab
- module ReplyByEmail
+ module IncomingEmail
class << self
def enabled?
config.enabled && address_formatted_correctly?
@@ -7,20 +7,14 @@ module Gitlab
def address_formatted_correctly?
config.address &&
- config.address.include?("%{reply_key}")
+ config.address.include?("%{key}")
end
- def reply_key
- return nil unless enabled?
-
- SecureRandom.hex(16)
- end
-
- def reply_address(reply_key)
- config.address.gsub('%{reply_key}', reply_key)
+ def reply_address(key)
+ config.address.gsub('%{key}', key)
end
- def reply_key_from_address(address)
+ def key_from_address(address)
regex = address_regex
return unless regex
@@ -33,7 +27,7 @@ module Gitlab
private
def config
- Gitlab.config.reply_by_email
+ Gitlab.config.incoming_email
end
def address_regex
@@ -41,7 +35,7 @@ module Gitlab
return nil unless wildcard_address
regex = Regexp.escape(wildcard_address)
- regex = regex.gsub(Regexp.escape('%{reply_key}'), "(.+)")
+ regex = regex.gsub(Regexp.escape('%{key}'), "(.+)")
Regexp.new(regex).freeze
end
end
diff --git a/lib/gitlab/markdown/relative_link_filter.rb b/lib/gitlab/markdown/relative_link_filter.rb
index 8c5cf51bfe1..6ee3d1ce039 100644
--- a/lib/gitlab/markdown/relative_link_filter.rb
+++ b/lib/gitlab/markdown/relative_link_filter.rb
@@ -59,25 +59,43 @@ module Gitlab
end
def relative_file_path(path)
- nested_path = build_nested_path(path, context[:requested_path])
+ nested_path = build_relative_path(path, context[:requested_path])
file_exists?(nested_path) ? nested_path : path
end
- # Covering a special case, when the link is referencing file in the same
- # directory.
- # If we are at doc/api/README.md and the README.md contains relative
- # links like [Users](users.md), this takes the request
- # path(doc/api/README.md) and replaces the README.md with users.md so the
- # path looks like doc/api/users.md.
- # If we are at doc/api and the README.md shown in below the tree view
- # this takes the request path(doc/api) and adds users.md so the path
- # looks like doc/api/users.md
- def build_nested_path(path, request_path)
+ # Convert a relative path into its correct location based on the currently
+ # requested path
+ #
+ # path - Relative path String
+ # request_path - Currently-requested path String
+ #
+ # Examples:
+ #
+ # # File in the same directory as the current path
+ # build_relative_path("users.md", "doc/api/README.md")
+ # # => "doc/api/users.md"
+ #
+ # # File in the same directory, which is also the current path
+ # build_relative_path("users.md", "doc/api")
+ # # => "doc/api/users.md"
+ #
+ # # Going up one level to a different directory
+ # build_relative_path("../update/7.14-to-8.0.md", "doc/api/README.md")
+ # # => "doc/update/7.14-to-8.0.md"
+ #
+ # Returns a String
+ def build_relative_path(path, request_path)
return request_path if path.empty?
return path unless request_path
parts = request_path.split('/')
parts.pop if path_type(request_path) != 'tree'
+
+ while parts.length > 1 && path.start_with?('../')
+ parts.pop
+ path.sub!('../', '')
+ end
+
parts.push(path).join('/')
end
diff --git a/lib/support/nginx/gitlab_ci b/lib/support/nginx/gitlab_ci
index ce179d6f599..bf05edfd780 100644
--- a/lib/support/nginx/gitlab_ci
+++ b/lib/support/nginx/gitlab_ci
@@ -18,18 +18,6 @@ server {
proxy_pass $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
}
- # expose build endpoint to allow trigger builds
- location ~ ^/projects/\d+/build$ {
- proxy_read_timeout 300;
- proxy_connect_timeout 300;
- proxy_redirect off;
- proxy_set_header X-Real-IP $remote_addr;
-
- # You need to specify your DNS servers that are able to resolve YOUR_GITLAB_SERVER_FQDN
- resolver 8.8.8.8 8.8.4.4;
- proxy_pass $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
- }
-
# redirect all other CI requests
location / {
return 301 $scheme://YOUR_GITLAB_SERVER_FQDN/ci$request_uri;
diff --git a/lib/tasks/gitlab/check.rake b/lib/tasks/gitlab/check.rake
index b8eb13a4fea..c8222f8ce11 100644
--- a/lib/tasks/gitlab/check.rake
+++ b/lib/tasks/gitlab/check.rake
@@ -2,7 +2,7 @@ namespace :gitlab do
desc "GitLab | Check the configuration of GitLab and its environment"
task check: %w{gitlab:gitlab_shell:check
gitlab:sidekiq:check
- gitlab:reply_by_email:check
+ gitlab:incoming_email:check
gitlab:ldap:check
gitlab:app:check}
@@ -634,13 +634,13 @@ namespace :gitlab do
end
- namespace :reply_by_email do
+ namespace :incoming_email do
desc "GitLab | Check the configuration of Reply by email"
task check: :environment do
warn_user_is_not_gitlab
start_checking "Reply by email"
- if Gitlab.config.reply_by_email.enabled
+ if Gitlab.config.incoming_email.enabled
check_address_formatted_correctly
check_mail_room_config_exists
check_imap_authentication
@@ -665,12 +665,12 @@ namespace :gitlab do
def check_address_formatted_correctly
print "Address formatted correctly? ... "
- if Gitlab::ReplyByEmail.address_formatted_correctly?
+ if Gitlab::IncomingEmail.address_formatted_correctly?
puts "yes".green
else
puts "no".red
try_fixing_it(
- "Make sure that the address in config/gitlab.yml includes the '%{reply_key}' placeholder."
+ "Make sure that the address in config/gitlab.yml includes the '%{key}' placeholder."
)
fix_and_rerun
end
@@ -689,7 +689,7 @@ namespace :gitlab do
"Enable mail_room in the init.d configuration."
)
for_more_information(
- "doc/reply_by_email/README.md"
+ "doc/incoming_email/README.md"
)
fix_and_rerun
end
@@ -708,7 +708,7 @@ namespace :gitlab do
"Enable mail_room in your Procfile."
)
for_more_information(
- "doc/reply_by_email/README.md"
+ "doc/incoming_email/README.md"
)
fix_and_rerun
end
@@ -753,7 +753,7 @@ namespace :gitlab do
"Check that the information in config/mail_room.yml is correct"
)
for_more_information(
- "doc/reply_by_email/README.md"
+ "doc/incoming_email/README.md"
)
fix_and_rerun
end
@@ -789,7 +789,7 @@ namespace :gitlab do
"Check that the information in config/mail_room.yml is correct"
)
for_more_information(
- "doc/reply_by_email/README.md"
+ "doc/incoming_email/README.md"
)
fix_and_rerun
end
diff --git a/spec/controllers/projects/compare_controller_spec.rb b/spec/controllers/projects/compare_controller_spec.rb
index b643b354073..2a447248b70 100644
--- a/spec/controllers/projects/compare_controller_spec.rb
+++ b/spec/controllers/projects/compare_controller_spec.rb
@@ -22,4 +22,30 @@ describe Projects::CompareController do
expect(assigns(:diffs).length).to be >= 1
expect(assigns(:commits).length).to be >= 1
end
+
+ describe 'non-existent refs' do
+ it 'invalid source ref' do
+ get(:show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ from: 'non-existent',
+ to: ref_to)
+
+ expect(response).to be_success
+ expect(assigns(:diffs)).to eq([])
+ expect(assigns(:commits)).to eq([])
+ end
+
+ it 'invalid target ref' do
+ get(:show,
+ namespace_id: project.namespace.to_param,
+ project_id: project.to_param,
+ from: ref_from,
+ to: 'non-existent')
+
+ expect(response).to be_success
+ expect(assigns(:diffs)).to eq(nil)
+ expect(assigns(:commits)).to eq(nil)
+ end
+ end
end
diff --git a/spec/lib/gitlab/email/receiver_spec.rb b/spec/lib/gitlab/email/receiver_spec.rb
index 1cc80f35f98..e470b7cd5f5 100644
--- a/spec/lib/gitlab/email/receiver_spec.rb
+++ b/spec/lib/gitlab/email/receiver_spec.rb
@@ -2,7 +2,7 @@ require "spec_helper"
describe Gitlab::Email::Receiver do
before do
- stub_reply_by_email_setting(enabled: true, address: "reply+%{reply_key}@appmail.adventuretime.ooo")
+ stub_incoming_email_setting(enabled: true, address: "reply+%{key}@appmail.adventuretime.ooo")
end
let(:reply_key) { "59d8df8370b7e95c5a49fbf86aeb2c93" }
diff --git a/spec/lib/gitlab/incoming_email_spec.rb b/spec/lib/gitlab/incoming_email_spec.rb
new file mode 100644
index 00000000000..5fdb9c723b1
--- /dev/null
+++ b/spec/lib/gitlab/incoming_email_spec.rb
@@ -0,0 +1,61 @@
+require "spec_helper"
+
+describe Gitlab::IncomingEmail do
+ describe "self.enabled?" do
+ context "when reply by email is enabled" do
+ before do
+ stub_incoming_email_setting(enabled: true)
+ end
+
+ context "when the address is valid" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns true" do
+ expect(described_class.enabled?).to be_truthy
+ end
+ end
+
+ context "when the address is invalid" do
+ before do
+ stub_incoming_email_setting(address: "replies@example.com")
+ end
+
+ it "returns false" do
+ expect(described_class.enabled?).to be_falsey
+ end
+ end
+ end
+
+ context "when reply by email is disabled" do
+ before do
+ stub_incoming_email_setting(enabled: false)
+ end
+
+ it "returns false" do
+ expect(described_class.enabled?).to be_falsey
+ end
+ end
+ end
+
+ context "self.reply_address" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns the address with an interpolated reply key" do
+ expect(described_class.reply_address("key")).to eq("replies+key@example.com")
+ end
+ end
+
+ context "self.key_from_address" do
+ before do
+ stub_incoming_email_setting(address: "replies+%{key}@example.com")
+ end
+
+ it "returns reply key" do
+ expect(described_class.key_from_address("replies+key@example.com")).to eq("key")
+ end
+ end
+end
diff --git a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
index 7f4d67e403f..027336ceb73 100644
--- a/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
+++ b/spec/lib/gitlab/markdown/relative_link_filter_spec.rb
@@ -4,14 +4,16 @@ require 'spec_helper'
module Gitlab::Markdown
describe RelativeLinkFilter do
- def filter(doc)
- described_class.call(doc, {
+ def filter(doc, contexts = {})
+ contexts.reverse_merge!({
commit: project.commit,
project: project,
project_wiki: project_wiki,
ref: ref,
requested_path: requested_path
})
+
+ described_class.call(doc, contexts)
end
def image(path)
@@ -75,6 +77,22 @@ module Gitlab::Markdown
to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
end
+ it 'rebuilds relative URL for a file in the repo up one directory' do
+ relative_link = link('../api/README.md')
+ doc = filter(relative_link, requested_path: 'doc/update/7.14-to-8.0.md')
+
+ expect(doc.at_css('a')['href']).
+ to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
+ end
+
+ it 'rebuilds relative URL for a file in the repo up multiple directories' do
+ relative_link = link('../../../api/README.md')
+ doc = filter(relative_link, requested_path: 'doc/foo/bar/baz/README.md')
+
+ expect(doc.at_css('a')['href']).
+ to eq "/#{project_path}/blob/#{ref}/doc/api/README.md"
+ end
+
it 'rebuilds relative URL for a file in the repo with an anchor' do
doc = filter(link('README.md#section'))
expect(doc.at_css('a')['href']).
@@ -108,8 +126,8 @@ module Gitlab::Markdown
escaped = Addressable::URI.escape(path)
# Stub these methods so the file doesn't actually need to be in the repo
- allow_any_instance_of(described_class).to receive(:file_exists?).
- and_return(true)
+ allow_any_instance_of(described_class).
+ to receive(:file_exists?).and_return(true)
allow_any_instance_of(described_class).
to receive(:image?).with(path).and_return(true)
diff --git a/spec/lib/gitlab/reply_by_email_spec.rb b/spec/lib/gitlab/reply_by_email_spec.rb
deleted file mode 100644
index a678c7e1a76..00000000000
--- a/spec/lib/gitlab/reply_by_email_spec.rb
+++ /dev/null
@@ -1,86 +0,0 @@
-require "spec_helper"
-
-describe Gitlab::ReplyByEmail do
- describe "self.enabled?" do
- context "when reply by email is enabled" do
- before do
- stub_reply_by_email_setting(enabled: true)
- end
-
- context "when the address is valid" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns true" do
- expect(described_class.enabled?).to be_truthy
- end
- end
-
- context "when the address is invalid" do
- before do
- stub_reply_by_email_setting(address: "replies@example.com")
- end
-
- it "returns false" do
- expect(described_class.enabled?).to be_falsey
- end
- end
- end
-
- context "when reply by email is disabled" do
- before do
- stub_reply_by_email_setting(enabled: false)
- end
-
- it "returns false" do
- expect(described_class.enabled?).to be_falsey
- end
- end
- end
-
- describe "self.reply_key" do
- context "when enabled" do
- before do
- allow(described_class).to receive(:enabled?).and_return(true)
- end
-
- it "returns a random hex" do
- key = described_class.reply_key
- key2 = described_class.reply_key
-
- expect(key).not_to eq(key2)
- end
- end
-
- context "when disabled" do
- before do
- allow(described_class).to receive(:enabled?).and_return(false)
- end
-
- it "returns nil" do
- expect(described_class.reply_key).to be_nil
- end
- end
- end
-
- context "self.reply_address" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns the address with an interpolated reply key" do
- expect(described_class.reply_address("key")).to eq("replies+key@example.com")
- end
- end
-
- context "self.reply_key_from_address" do
- before do
- stub_reply_by_email_setting(address: "replies+%{reply_key}@example.com")
- end
-
- it "returns reply key" do
- expect(described_class.reply_key_from_address("replies+key@example.com")).to eq("key")
- end
- end
-end
diff --git a/spec/models/ci/variable_spec.rb b/spec/models/ci/variable_spec.rb
index 97a3d0081f4..d034a6c7b9f 100644
--- a/spec/models/ci/variable_spec.rb
+++ b/spec/models/ci/variable_spec.rb
@@ -38,7 +38,8 @@ describe Ci::Variable do
it 'fails to decrypt if iv is incorrect' do
subject.encrypted_value_iv = nil
subject.instance_variable_set(:@value, nil)
- expect { subject.value }.to raise_error
+ expect { subject.value }.
+ to raise_error(OpenSSL::Cipher::CipherError, 'bad decrypt')
end
end
end
diff --git a/spec/models/ci/web_hook_spec.rb b/spec/models/ci/web_hook_spec.rb
index c4c0b007c11..bf9481ab81d 100644
--- a/spec/models/ci/web_hook_spec.rb
+++ b/spec/models/ci/web_hook_spec.rb
@@ -56,7 +56,8 @@ describe Ci::WebHook do
it "catches exceptions" do
expect(Ci::WebHook).to receive(:post).and_raise("Some HTTP Post error")
- expect{ @web_hook.execute(@data) }.to raise_error
+ expect{ @web_hook.execute(@data) }.
+ to raise_error(RuntimeError, 'Some HTTP Post error')
end
end
end
diff --git a/spec/requests/ci/api/projects_spec.rb b/spec/requests/ci/api/projects_spec.rb
index 2adae52e79e..409f47fa448 100644
--- a/spec/requests/ci/api/projects_spec.rb
+++ b/spec/requests/ci/api/projects_spec.rb
@@ -165,7 +165,8 @@ describe Ci::API::API do
project.gl_project.team << [user, :master]
delete ci_api("/projects/#{project.id}"), options
expect(response.status).to eq(200)
- expect { project.reload }.to raise_error
+ expect { project.reload }.
+ to raise_error(ActiveRecord::RecordNotFound)
end
it "non-manager is not authorized" do
diff --git a/spec/services/ci/create_project_service_spec.rb b/spec/services/ci/create_project_service_spec.rb
index c0af515aa8f..2de7b0deca7 100644
--- a/spec/services/ci/create_project_service_spec.rb
+++ b/spec/services/ci/create_project_service_spec.rb
@@ -15,7 +15,8 @@ describe Ci::CreateProjectService do
context 'without project dump' do
it 'should raise exception' do
- expect { service.execute(current_user, '', '') }.to raise_error
+ expect { service.execute(current_user, '', '') }.
+ to raise_error(NoMethodError)
end
end
diff --git a/spec/support/stub_configuration.rb b/spec/support/stub_configuration.rb
index ef3a120d44a..f40ee862df8 100644
--- a/spec/support/stub_configuration.rb
+++ b/spec/support/stub_configuration.rb
@@ -17,8 +17,8 @@ module StubConfiguration
allow(Gitlab.config.gravatar).to receive_messages(messages)
end
- def stub_reply_by_email_setting(messages)
- allow(Gitlab.config.reply_by_email).to receive_messages(messages)
+ def stub_incoming_email_setting(messages)
+ allow(Gitlab.config.incoming_email).to receive_messages(messages)
end
private
diff --git a/spec/workers/email_receiver_worker_spec.rb b/spec/workers/email_receiver_worker_spec.rb
index e8f1bd2fa2f..65a8d7d9197 100644
--- a/spec/workers/email_receiver_worker_spec.rb
+++ b/spec/workers/email_receiver_worker_spec.rb
@@ -5,7 +5,7 @@ describe EmailReceiverWorker do
context "when reply by email is enabled" do
before do
- allow(Gitlab::ReplyByEmail).to receive(:enabled?).and_return(true)
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(true)
end
it "calls the email receiver" do
@@ -33,7 +33,7 @@ describe EmailReceiverWorker do
context "when reply by email is disabled" do
before do
- allow(Gitlab::ReplyByEmail).to receive(:enabled?).and_return(false)
+ allow(Gitlab::IncomingEmail).to receive(:enabled?).and_return(false)
end
it "doesn't call the email receiver" do