phlegx / redmine_gitlab_hook

This plugin allows you to update your local Git repositories in Redmine when changes have been pushed to GitLab.
MIT License
218 stars 73 forks source link

TypeError (Project 'project_name' ('project_name') has no repository) #38

Closed Sergey1000 closed 6 years ago

Sergey1000 commented 6 years ago

Hello. I'm try to use your awesome plugin. But I got some problem during the configuring. Here is my situation:

1. Software version (the first one - in Redmine, the seconf - in Gitlab):

Redmine version: 3.4.3.stable Ruby version: 2.3.1-p112 (2016-04-26) [x86_64-linux-gnu] Rails version: 4.2.8 Git: 2.7.4 redmine_gitlab_hook: 0.2.0

GitLab: 10.4.4 Ruby: 2.3.6p384 Rails: 4.2.10 Git: 2.14.3

2. Preconfiguration for Redmine:

Enable REST web service - check Enable WS for repository management - check Repository management WS API key - FITBJ4rk5j7jIcPQWefx

3. Projects and repositories (the first one - in Redmine, the seconf - in Gitlab):

Project name: test_project Repository id (linked to the test_project): test_repo_mirror Repository in filesystem: /var/www/redmine/files/repos/mirror/test_repo_in_gitlab.git How does the repository was cloning to the filesystem: git clone --mirror git@gitlab.lan:Lastname/test_repo_in_gitlab.git

Gitlab project name: http://gitlab.lan/Lastname/test_project_in_gitlab Gitlab repository: git@gitlab.lan:Lastname/test_repo_in_gitlab.git Webhook (push events): http://redmine.lan/gitlab_hook?project_id=test_project&key=FITBJ4rk5j7jIcPQWefx

4. What have I done:

Started POST "/gitlab_hook?project_id=test_project&key=FITBJ4rk5j7jIcPQWefx" for 192.168.0.50 at 2018-02-22 17:37:25 +0200
Processing by GitlabHookController#index as HTML
  Parameters: {"project_id"=>"test_project", "key"=>"FITBJ4rk5j7jIcPQWefx"}
Completed 500 Internal Server Error in 6ms (ActiveRecord: 1.7ms)

TypeError (Project 'test_project' ('test_project') has no repository):
  plugins/redmine_gitlab_hook/app/controllers/gitlab_hook_controller.rb:131:in `find_repository'
  plugins/redmine_gitlab_hook/app/controllers/gitlab_hook_controller.rb:11:in `index'

The same problem occured when I use ANY key too. Looks like it fails before the authorization;

But when I launch the next command, I can see, that repository is linked to the project: $ curl -v -u afb7a0addad5b0cf33449512a99879ff2cf40c9d:x "http://redmine.lan/sys/projects.xml?key=FITBJ4rk5j7jIcPQWefx" [{"id":2,"name":"test_project","is_public":true,"identifier":"test_project","status":1,"repository":{"id":11,"url":"/var/www/redmine/files/repos/mirror/test_repo_in_gitlab.git"}}]

I can't figure out, what's wrong in my situation. Could you, please, help with this? Thank you.

phlegx commented 6 years ago

You have no repository set up in the Redmine project. Please activate module "repository" on project settings and then config a repository under: http://redmine.lan/projects/test_project/settings/repositories.

Sergey1000 commented 6 years ago

Thank you so much for your extremely quick answer. As I understood, the repository was already setup in the Redmine project (regards to attached images). If I do "git fetch" in Redmine's mirror repo directory, I can see the changes, happened in Gitlab repo. Or I still do something wrong?

151931916172052088 151931916172052088 1

phlegx commented 6 years ago

@Sergey1000 please try out latest master. I have commit a bugfix. If all works fine for you I release a new version.

Sergey1000 commented 6 years ago

Thanks, I've tried it. And got the extended message: TypeError (Project 'test_project' ('test_project') has no repository or repository not found with identifier 'lastname_test_repo_in_gitlab'):

Looks like I need to set the Redmine's repository id as "lastname_test_repo_in_gitlab"? Or something else?

Sergey1000 commented 6 years ago

Wow! Looks like my dreams comes true. I've changed the repository id to required and "Gotcha!" - "Hook executed successfully: HTTP 200".

phlegx commented 6 years ago

Thx, I will release version 0.2.1. Added description how to set right repository id in repository settings.