Page MenuHomePhabricator

Add "Notify Jenkins on Commit" step for Harbormaster
Closed, DuplicatePublic

Description

The one way to integrate with Jenkins it to make HTTP request (as build step) to trigger a build. That's absolutely valid.

I would like to propose another way:

  1. we call .../notifyCommit url with commit details on Jenkins
  2. that would affect any job, that have polling enabled to start a build with that commit

Of course Jenkins host and credentials (username, api token) needs to be stored as Harbormaster configuration for this to work.

Here we are not triggering Jenkins build directly so there is no way for Jenkins to know how to contact Phabricator back, but that's ok for now.

I can implement proposed functionality.

P.S.
In my fork I've implemented Conduit API call that accepts repository.callsign, jenkins.jobName and jenkins.buildNumber so Jenkins can associate it's build with particular commit. If needed we can figure out the build with that commit as well, but that won't be part of this task.

Event Timeline

aik099 raised the priority of this task from to Needs Triage.
aik099 updated the task description. (Show Details)
aik099 added a project: Harbormaster.
aik099 added a subscriber: aik099.

Proposed approach have several advantages over the classic trigger build HTTP request approach:

  1. no need to create separate build, build step, herald rule for linking commit to build job for every repository under Phabricator, because all configuration happens on Jenkins side once per Job
  2. configure herald rule, build, build step once for current and future repositories

This new build step is a replacement of jenkins after commit hook that is placed within a repository to ensure that Jenkins build is started only, when a commit was fully imported in Phabricator.

Currently what happens for me:

  1. commit is created
  2. Jenkins is notified immediately via after commit hook and build is started
  3. Jenkins build is started
  4. Phabricator is notified over time (when poller finds out about that commit)
  5. Jenkins build finishes but with 80% chance the Phabricator haven't parsed commit by that time
  6. No build information is added to that commit in Phabricator

What will happen after this is implemented:

  1. commit is created
  2. Phabricator polls for commits and detects a commit
  3. Herald rule tigers Harbormaster build for that commit
  4. Harbormaster build notifiers Jenkins about new commit
  5. Jenkins starts a build
  6. Jenkins reports back to Phabricator with build results
epriestley triaged this task as Wishlist priority.Nov 11 2014, 12:46 PM
epriestley added a subscriber: epriestley.

We plan to pursue system-specific rules (e.g., for Jenkins, and maybe other popular CI platforms) eventually.

We never plan to support this as a commit hook.

Not Phabricator as commit hook (specified via repository commit hook), but Phabricator instead of commit hook from repository. So, when Phabricator discovers a commit, then via Herald rule, that triggers Harbormaster build it, that via new build step, can notify Jenkins of that commit.

Unknown Object (User) added a subscriber: Unknown Object (User).Nov 11 2014, 6:04 PM

:)

Those seems to do the job !

Side question ? Is there an api standardised (PhutilClass or so) to load coverage file ? How does internally arcanist coverage works ?

Hey there, I am the maintainer of the Phabricator Jenkins plugin. I am working on adding coverage (and unit) reporting from Jenkins -> Harbormaster now that the API exists. You can track our progress here: https://github.com/uber/phabricator-jenkins-plugin/issues/34 (I wish I had a public Phabricator to develop this on :))

First pass is going to support the Cobertura XML coverage format, and JUnit (and therefore also XUnit) test results.

I'm going to merge this into T7869 since that has a more complete view of things and our Jenkins plan looks like it's shaping up to pretty much be "tell people to use @sectioneight's plugin", give or take.