github / janky

Continuous integration server built on top of Jenkins and Hubot

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

/ci setup fails when a job already exists for the repository

aroben opened this issue · comments

I have a project I want to build on both Mac and Windows. To do this, I've created two jobs (project-osx.xml.erb and project-win.xml.erb). Setting up the first one works just fine:

/ci setup owner/repo project-osx

But setting up the second one fails because the GitHub Hooks API recently changed to disallow duplicate hooks on repositories:

/ci setup owner/repo project-win
{
  "message": "Validation Failed",
  "errors": [
    {
      "resource": "Hook",
      "code": "custom",
      "message": "Hook already exists on this repository"
    }
  ]
}
/data/janky/vendor/gems/ruby/1.9.1/bundler/gems/janky-8329fb2e67e2/lib/janky/github.rb:125:in `hook_create'
/data/janky/vendor/gems/ruby/1.9.1/bundler/gems/janky-8329fb2e67e2/lib/janky/repository.rb:146:in `setup_hook'
/data/janky/vendor/gems/ruby/1.9.1/bundler/gems/janky-8329fb2e67e2/lib/janky/repository.rb:138:in `setup'
/data/janky/vendor/gems/ruby/1.9.1/bundler/gems/janky-8329fb2e67e2/lib/janky/repository.rb:36:in `setup'
/data/janky/vendor/gems/ruby/1.9.1/bundler/gems/janky-8329fb2e67e2/lib/janky/hubot.rb:15:in `block in '

/cc @technoweenie

What would you expect to happen? The hook is there....

I don't think this is necessarily an issue with the GitHub API. Probably we need to fix Janky to handle this case.

@aroben Got it. Thanks for figuring this all out. I am hoping to do some much needed maintenance on github/ci 🔜 and will look into this. If this is blocking you let me know and I'll hack around it.

BTW, my current workaround for this is to first run /ci setup and let it fail, then:

$ ssh janky
$ cd /data/janky
$ RACK_ENV=production FAILBOT_BACKEND=memory script/console
> repo = Janky::Repository.by_name('new-job-name')
> existing = Janky::Repository.by_name('existing-job-name')
> repo.hook_url = existing.hook_url
> repo.save!
> repo.setup_job

After that, everything works fine.