Jenkins integration

Issue #857 resolved
moparisthebest created an issue

My company runs rhodecode for a mercurial server, and jenkins for a build server. I install, upgrade, and maintain these installations, in addition to writing the integration code for these two services. It basically consists of the following:

  1. An extra checkbox when forking a repository to create a new jenkins job
  2. Buttons on the main listing to create a jenkins job and/or start a build for that repository
  3. A hook to start a jenkins build when a repository is pushed to

The jenkins config, javascript code for jenkins API, and the python hook to trigger jenkins builds on mercurial pushes never changes across rhodecode versions. The patch to implement the rather simple UI changes does. I have attached everything needed to implement this integration.

Obviously things are specific to my company, like assuming both services run on the same computer under the /hg/ and /jenkins/ URLs, and some logic as to which jenkins config.xml to use.

So my question here is would you be interested in accepting a patch/change into the mainline rhodecode that implemented these changes, but with additional configuration so it could be enabled/disabled and configured from the Settings menu? If not just go ahead and close this issue, and I'll continue maintaining this specifically for my company. If so, what kind of settings would you like to see editable in the GUI? At a minimum it would need the jenkins URL, rhodecode URL, and a path to the jenkin's config.xml they want to use, possibly on a project-level basis.

Thanks for the great software, hopefully I can get a chance to help improve it.

Comments (6)

  1. moparisthebest reporter

    Jenkins links on dashboard, left one creates a job if it doesn't exist, and takes you to that jenkins job. Right one creates a job if it doesn't exist, starts a build, and takes you to the output for that build. All functionality currently implemented as javascript onclick functions.

  2. moparisthebest reporter

    I went ahead and implemented as much of this integration as I can as built-in rhodecode hooks in rcextensions/init.py. There are still just a few (search for word CHANGE) things hard-coded until:

    1. Rhodecode gets server-wide extra fields and/or extra fields can be specified on create and/or copied over on fork.
    2. Rhodecode passes the extra-fields into the hooks.

    At that time it will be trivial to change this code to use those fields instead.

    Writing this I realize I also need 2 additional hooks:

    1. Repository rename or move to another group, both of these effectively move the location of the repository so the jenkins job needs renamed and pointed to the new location.
    2. Extra fields change, if parameters such as 'create jenkins job' or 'jenkins_server_url' etc etc change, I'll need to make the appropriate changes on the jenkins side.

    Any thoughts on creating those hooks?

    Also any comments on my python code is welcome, I haven't written it in years and am not super confident everything is "right", it does work, but you know how that is. :)

  3. moparisthebest reporter

    Just realized I didn't say exactly what the new hook-only integration entails. It creates a jenkins job based on the project you forked it from's jenkin's job, falling back to a default config if the project isn't forked from anything or the fork doesn't have a jenkins job. It tries to create this job on repository create, repository push, and repository pull.

    It tells you about the status of your last build when you push, whether it failed, succeeded, and if it failed, the last build that did succeed. It also schedules repository polling (and therefore a build) on a push.

    It deletes your jenkins job when the repository is deleted.

  4. Marcin Kuzminski repo owner

    Our new integrations framework in 4.5 release can nicely handle Jenkins etc, however we will continue to improve that support.

    Closing due to ticket being not valid anymore. Please check https://issues.rhodecode.com for current open tickets or to open a new one against latest 4.X releases.

  5. Log in to comment