Commit 660e4604 authored by Achilleas Pipinellis's avatar Achilleas Pipinellis

Merge branch 'master' of github.com:gitlabhq/gitlab-recipes

parents dc937dc8 79f6b9ae
......@@ -10,6 +10,12 @@ require 'net/http'
@host="host"
@base_url="https://#{@host}/"
def gitlab_key(email,password)
uri = URI("#{@base_url}/api/v3/session")
res = Net::HTTP.post_form(uri, 'email' => email, 'password' => password)
JSON.parse(res.body)['private_token']
end
## Add your credentials here
@token=gitlab_key('user','password')
......@@ -28,36 +34,10 @@ require 'net/http'
## Kick off the import ##
#########################
import(load_bitbucket())
def load_bitbucket()
JSON.parse(IO.read('db-1.0.json'))
end
def import(bitbucket_json)
id_map={}
bitbucket_json['issues'].each do |issue|
issue_id=issue['id']
gitlab_id=post_issue(issue['title'],issue['content'])
id_map[issue_id]=gitlab_id
if('resolved' == issue['status'])
close_issue(gitlab_id)
end
end
bitbucket_json['comments'].each do |comment|
if comment['content']
post_comment(id_map[comment['issue']],"#{comment['content']}\n\n#{comment['user']} - #{comment['created_on']}")
end
end
end
def gitlab_key(email,password)
uri = URI("#{@base_url}/api/v3/session")
res = Net::HTTP.post_form(uri, 'email' => email, 'password' => password)
JSON.parse(res.body)['private_token']
end
def post_issue(title,description)
uri = URI("#{@base_url}/api/v3/projects/#{@project}/issues")
res = Net::HTTP.post_form(uri, 'title' => title, 'description' => description, 'private_token' => @token, 'labels' => ['bitbucket2gitlab'])
......@@ -66,13 +46,6 @@ def post_issue(title,description)
created['id']
end
def post_comment(id,content)
uri = URI("#{@base_url}/api/v3/projects/#{@project}/issues/#{id}/notes")
res = Net::HTTP.post_form(uri, 'body' => content,'private_token' => @token)
created=JSON.parse(res.body)
puts created.to_json
end
def close_issue(id)
# uri = URI("#{@base_url}/api/v3/projects/#{@project}/issues")
......@@ -85,6 +58,33 @@ def close_issue(id)
puts response.body
end
def post_comment(id,content)
uri = URI("#{@base_url}/api/v3/projects/#{@project}/issues/#{id}/notes")
res = Net::HTTP.post_form(uri, 'body' => content,'private_token' => @token)
created=JSON.parse(res.body)
puts created.to_json
end
def import(bitbucket_json)
id_map={}
bitbucket_json['issues'].each do |issue|
issue_id=issue['id']
gitlab_id=post_issue(issue['title'],issue['content'])
id_map[issue_id]=gitlab_id
if('resolved' == issue['status'])
close_issue(gitlab_id)
end
end
bitbucket_json['comments'].each do |comment|
if comment['content']
post_comment(id_map[comment['issue']],"#{comment['content']}\n\n#{comment['user']} - #{comment['created_on']}")
end
end
end
import(load_bitbucket())
def get_issues()
request = Net::HTTP::Get.new("/api/v3/projects/#{@project}/issues?private_token=#{@token}")
response=@http.request(request)
......
......@@ -7,7 +7,7 @@ GitLab requires a couple of services:
* GitLab Sidekiq service (`gitlab-sidekiq.service`)
* Unicorn service (`gitlab-unicorn.service`)
* Gitlab Workhorse server for slow HTTP requests (`gitlab-workhorse.service`)
* Gitaly, the Git RPC service for handling all the git calls made by GitLab (`gitlab.gitaly.service`)
* Gitaly, the Git RPC service for handling all the git calls made by GitLab (`gitlab-gitaly.service`)
## Setup GitLab services
......@@ -29,11 +29,11 @@ Reload systemd:
Start the services:
sudo systemctl start gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service
sudo systemctl start gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service gitlab-gitaly.service
Enable them to start at boot:
sudo systemctl enable gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service
sudo systemctl enable gitlab-sidekiq.service gitlab-unicorn.service gitlab-workhorse.service gitlab-mailroom.service gitlab-gitaly.service
## Notes
......
......@@ -15,6 +15,14 @@ Open `/etc/gitlab/gitlab.rb` using your favourite text editor and update the fol
* Change `nginx['enable'] = "true"` to `nginx['enable'] = "false"`
* Save and exit the configuration file and run `gitlab-ctl reconfigure` to update gitlabs configuration
#### Issues
With some repository you can get the following [error](https://gitlab.com/gitlab-org/gitlab-ci-multi-runner/issues/1587)
in order to fix ensure to modify this line in `/etc/gitlab/gitlab.rb`
* `nginx['custom_gitlab_server_config'] = 'proxy_buffering off;'`
* Save and exit the configuration file and run `gitlab-ctl reconfigure` to update gitlabs configuration
### Updating the Caddyfile
Simply change gitlab.example.com to point to your FQDN.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment