mirror of
https://github.com/gitlabhq/gitlab-recipes.git
synced 2026-01-09 14:37:57 -05:00
Merge branch 'master' of github.com:gitlabhq/gitlab-recipes
This commit is contained in:
@@ -10,6 +10,12 @@ require 'net/http'
|
|||||||
@host="host"
|
@host="host"
|
||||||
@base_url="https://#{@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
|
## Add your credentials here
|
||||||
@token=gitlab_key('user','password')
|
@token=gitlab_key('user','password')
|
||||||
|
|
||||||
@@ -28,12 +34,37 @@ require 'net/http'
|
|||||||
## Kick off the import ##
|
## Kick off the import ##
|
||||||
#########################
|
#########################
|
||||||
|
|
||||||
import(load_bitbucket())
|
|
||||||
|
|
||||||
def load_bitbucket()
|
def load_bitbucket()
|
||||||
JSON.parse(IO.read('db-1.0.json'))
|
JSON.parse(IO.read('db-1.0.json'))
|
||||||
end
|
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)
|
def import(bitbucket_json)
|
||||||
id_map={}
|
id_map={}
|
||||||
bitbucket_json['issues'].each do |issue|
|
bitbucket_json['issues'].each do |issue|
|
||||||
@@ -52,38 +83,7 @@ def import(bitbucket_json)
|
|||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def gitlab_key(email,password)
|
import(load_bitbucket())
|
||||||
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
|
|
||||||
|
|
||||||
def get_issues()
|
def get_issues()
|
||||||
request = Net::HTTP::Get.new("/api/v3/projects/#{@project}/issues?private_token=#{@token}")
|
request = Net::HTTP::Get.new("/api/v3/projects/#{@project}/issues?private_token=#{@token}")
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ GitLab requires a couple of services:
|
|||||||
* GitLab Sidekiq service (`gitlab-sidekiq.service`)
|
* GitLab Sidekiq service (`gitlab-sidekiq.service`)
|
||||||
* Unicorn service (`gitlab-unicorn.service`)
|
* Unicorn service (`gitlab-unicorn.service`)
|
||||||
* Gitlab Workhorse server for slow HTTP requests (`gitlab-workhorse.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
|
## Setup GitLab services
|
||||||
|
|
||||||
@@ -29,11 +29,11 @@ Reload systemd:
|
|||||||
|
|
||||||
Start the services:
|
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:
|
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
|
## 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"`
|
* Change `nginx['enable'] = "true"` to `nginx['enable'] = "false"`
|
||||||
* Save and exit the configuration file and run `gitlab-ctl reconfigure` to update gitlabs configuration
|
* 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
|
### Updating the Caddyfile
|
||||||
|
|
||||||
Simply change gitlab.example.com to point to your FQDN.
|
Simply change gitlab.example.com to point to your FQDN.
|
||||||
|
|||||||
Reference in New Issue
Block a user