Re-use Git Plugin webhook

35 views
Skip to first unread message

Carles Capdevila Tejada

unread,
Oct 24, 2017, 11:11:52 AM10/24/17
to Jenkins Developers

Hi there,

 

I’m writing an organization plugin for Gitblit (something like Github-branch-source) and I read in the docs that to implement the automatic triggering of jobs when pushing to the SCM a webhook should be implemented. However, I’d like to re-use the webhook of the Git Plugin to do this.

Right now the Gitblit organization projects are not detected by the Git “notifyCommit” webhook given that they are WorkflowJob’s and their getSCMs() method does not see any checkout in the previous builds.

What's more, it seems that the Git hook only acts on the branches already scanned in Jenkins, so it doesn't seem posible to trigger a scan when a new repository/branch is created and pushed into in Gitblit.

 

Is trying to re-use the Git Plugin webhook for an organization plugin a good/bad idea?

Thank you for your attention.

Jesse Glick

unread,
Oct 24, 2017, 11:57:47 AM10/24/17
to Jenkins Dev
On Tue, Oct 24, 2017 at 11:08 AM, Carles Capdevila Tejada
<capde...@gmail.com> wrote:
> I read in the docs that to implement the automatic
> triggering of jobs when pushing to the SCM a webhook should be implemented.
> However, I’d like to re-use the webhook of the Git Plugin to do this.

Sure. `github-branch-source` does this. Study it as a kind of
reference implementation, as well as

https://github.com/jenkinsci/scm-api-plugin/blob/master/docs/implementation.adoc

> Right now the Gitblit organization projects are not detected by the Git
> “notifyCommit” webhook given that they are WorkflowJob’s and their getSCMs()
> method does not see any checkout in the previous builds.

You mean, you have standalone Pipeline projects using this SCM. That
is very different from implementing `SCMSource` + `SCMNavigator`.

> What's more, it seems that the Git hook only acts on the branches already
> scanned in Jenkins, so it doesn't seem posible to trigger a scan when a new
> repository/branch is created and pushed into in Gitblit.

So long as Gitblit sends some kind of event when a branch is created,
you should be able to listen to that event.

Carles Capdevila Tejada

unread,
Dec 1, 2017, 11:10:18 AM12/1/17
to Jenkins Developers
I solved this by making the 'SCMSource' (GitBlitSCMSource) extend GitSCMSource instead of AbstractGitSCMSource, so far no problems with it, the branches get updated and new branches are also detected on first push.

Thanks!
Reply all
Reply to author
Forward
0 new messages