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

This commit is contained in:
Achilleas Pipinellis
2017-08-15 07:54:00 +03:00
3 changed files with 45 additions and 37 deletions

View File

@@ -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,12 +34,37 @@ require 'net/http'
## Kick off the import ##
#########################
import(load_bitbucket())
def load_bitbucket()
JSON.parse(IO.read('db-1.0.json'))
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'])
created=JSON.parse(res.body)
puts created.to_json
created['id']
end
def close_issue(id)
# uri = URI("#{@base_url}/api/v3/projects/#{@project}/issues")
request = Net::HTTP::Put.new("/api/v3/projects/#{@project}/issues/#{id}")
request.set_form_data({'private_token' => @token,'state_event'=>'close'})
response=@http.request(request)
puts response.inspect
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|
@@ -52,38 +83,7 @@ def import(bitbucket_json)
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'])
created=JSON.parse(res.body)
puts created.to_json
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")
request = Net::HTTP::Put.new("/api/v3/projects/#{@project}/issues/#{id}")
request.set_form_data({'private_token' => @token,'state_event'=>'close'})
response=@http.request(request)
puts response.inspect
puts response.body
end
import(load_bitbucket())
def get_issues()
request = Net::HTTP::Get.new("/api/v3/projects/#{@project}/issues?private_token=#{@token}")

View File

@@ -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

View File

@@ -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.