elvanja / jenkins-gitlab-hook-plugin

Enables Gitlab web hooks to be used to trigger SMC polling on Gitlab projects
142 stars 81 forks source link

"no project references the given repo url and commit branch" muti-branch freestyle #59

Open stephaneerard opened 9 years ago

stephaneerard commented 9 years ago

Hi,

First, thank you for your plugin !

I'm trying your plugin using multi-branch project style and hitting a wall : "no project references the given repo url and commit branch"

Here is my setting:

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
dd171360530b sameersbn/gitlab:7.11.0 "/app/init app:start 4 minutes ago Up 4 minutes 443/tcp, 0.0.0.0:10022->22/tcp, 0.0.0.0:10080->80/tcp
077fddf03c21 sameersbn/redis:latest "/start" 4 minutes ago Up 4 minutes 6379/tcp
83fee3e63d59 sameersbn/postgresql:9.4 "/start" 4 minutes ago Up 4 minutes 5432/tcp
6c9d19e73cef enalean/tuleap-aio:latest "/root/app/run.sh" 49 minutes ago Up 48 minutes 0.0.0.0:80->80/tcp, 22/tcp, 0.0.0.0:443->443/tcp tuleap
7a7e0b55df6f jenkins:latest "/usr/local/bin/jenk 55 minutes ago Up 55 minutes 50000/tcp, 0.0.0.0:8090->8080/tcp

Adding a commit in a branch (git flow)

serard@ubuntu:~/test-prj/test$ echo 1 >> README; git add -A; git commit -m"test"; git push
[hotfix/1.0.1 281a57c] test
 1 file changed, 1 insertion(+)
Décompte des objets: 3, fait.
Écriture des objets: 100% (3/3), 236 bytes | 0 bytes/s, fait.
Total 3 (delta 0), reused 0 (delta 0)
To ssh://git@192.168.0.17:10022/root/test.git
   fbd3c09..281a57c  hotfix/1.0.1 -> hotfix/1.0.1
serard@ubuntu:~/test-prj/test$

Stack trace in jenkins logs :

May 21, 2015 9:43:58 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
INFO: gitlab web hook triggered for
   - repo url: ssh://git@192.168.0.17:10022/root/test.git
   - branch: hotfix/1.0.1
   - with payload:
{
  "object_kind": "push",
  "before": "fbd3c09bc6f6c2f40eb22d2e4962e5069137dfa6",
  "after": "281a57ce4de936645d92d3f4cb3e18e88641c958",
  "ref": "refs/heads/hotfix/1.0.1",
  "checkout_sha": "281a57ce4de936645d92d3f4cb3e18e88641c958",
  "message": null,
  "user_id": 1,
  "user_name": "Administrator",
  "user_email": "admin@example.com",
  "project_id": 1,
  "repository": {
    "name": "test",
    "url": "ssh://git@192.168.0.17:10022/root/test.git",
    "description": "test",
    "homepage": "http://192.168.0.17:10080/root/test",
    "git_http_url": "http://192.168.0.17:10080/root/test.git",
    "git_ssh_url": "ssh://git@192.168.0.17:10022/root/test.git",
    "visibility_level": 10
  },
  "commits": [
    {
      "id": "281a57ce4de936645d92d3f4cb3e18e88641c958",
      "message": "test\n",
      "timestamp": "2015-05-21T23:43:57+02:00",
      "url": "http://192.168.0.17:10080/root/test/commit/281a57ce4de936645d92d3f4cb3e18e88641c958",
      "author": {
        "name": "Your Name",
        "email": "you@example.com"
      }
    }
  ],
  "total_commits_count": 1
}
May 21, 2015 9:43:58 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
INFO: matching projects:
   - test/develop
   - test/hotfix/1.0.1
   - test/master
   - test/release/1
May 21, 2015 9:43:58 PM org.jruby.javasupport.JavaMethod invokeDirectWithExceptionHandling
WARNING: no project references the given repo url and commit branch

Obviously I want it to trigger a build for test/hotfix/1.0.1 :) Is it made to work this way ?

Going to the configuration of the sub-project : http://192.168.0.17:8090/job/test/branch/hotfix%2F1.0.1/configure I can see the "Branches to build Branch Specifier (blank for 'any')" parameter is set to "hotfix/1.0.1".

Thank you very much !

elvanja commented 9 years ago

Hi @stephaneerard! I haven't been into this plugin for quite some time now. The best I can tell is that the project is recognized to match the commit/payload (it shows in the matching list) but for some reason is not triggered to be built. Maybe @javiplx can help you with that one further, he's taken up the development of the plugin lately. Thank you!

javiplx commented 9 years ago

The point is on

I can see the "Branches to build Branch Specifier (blank for 'any')" parameter is set to "hotfix/1.0.1".

That will never produce a match, because when there is a / on the branch specifier, git plugin requires the remote name to be there. So, either origin/ or */ should be the leading text on branch specifier.