Tags

, ,

It is not very wise to poll repository for Jenkins jobs. A better approach will be configuring repository so that it will trigger when there is a significant change. This may be done by hooks of git. As a first step, Jenkins job should have polling SCM enabled in build options.

git jenkins trigger - poll scm check

Then check trigger from terminal using curl (if not already present install it using apt-get curl).

git jenkins trigger - curl command line

The line complaining about repository usage should not appear important when we check polling logs of git, as this is a test run, actually there is no repository change.

git jenkins trigger - git polling log

Copy ‘curl’ command to ‘post-receive’ hook of git repository. post-receive hook will be executed after a new commit is pushed to server.

git jenkins trigger - post receive hook

After a real commit, we may also see the log of trigger at ‘git push’ result. (Yes, working on master instead of creating a branch is a shame!)

git jenkins trigger - git commit

Notice that, there is a repository change now, so this triggers a new build as may be seen below,

git jenkins trigger - git polling build log

Advertisements