0

I'm trying to set up jenkins so that when a commit on a repo is detected, the build in jenkins automatically triggers. I've been reading this post: How can I make Jenkins CI with git trigger on pushes to master?

But it's not clear to me where I create the git hook "post-receive". So far, I've tried two different spots:

  • on the jenkins server, in the workspace folder that was automatically created for me when I set up this new project with the git repo specified.
  • on the developer workstation I use to make my coding changes for this repo.

Neither one is working. This is what the post-receive file looks like:

me@jenkinslab:/var/lib/jenkins/jobs/test git repo/workspace/.git/hooks$ cat post-receive
#!/bin/sh
#
# An example hook script to prepare a packed repository for use over
# dumb transports.
#
# To enable this hook, rename this file to "post-update".
curl http://10.1.1.11:8080/jenkins/git/notifyCommit?url=http://git.someinternaldomain.net/cgit/testing.git[&branches=branch1[,branch2]*][&sha1=<commit ID>]

In addition to creating this file, in my jenkins project, i have the "Poll SCM" option checked off under the "Build Triggers" section, but nothing as far as schedule defined.

Can you tell me what I'm missing?

Please and thanks.

Community
  • 1
  • 1
Happydevdays
  • 1,982
  • 5
  • 31
  • 57

2 Answers2

1

It goes on the git server. If you're using github.com, then they have it all set up for you in the UI, you just need to put the URL in the right place: Your repo, Settings, Webhooks and Services.

Ewan Mellor
  • 6,747
  • 1
  • 24
  • 39
  • i just created a post-update hook on the git server, and then submitted a change to the repo. Jenkins build did not trigger. Just wondering what I can do on the server to see if the git hook triggered or not? – Happydevdays Jun 10 '16 at 18:51
0

This should be triggered from the post-receive hook (not the post-update) on the GIT server.

What kind of git server are you using? The solution may be different for each kind of server (github, BitBucket, etc.).

yorammi
  • 6,272
  • 1
  • 28
  • 34