How to trigger a build remotely from Jenkins?
How to configure Git post commit hook?
My requirement is whenever changes are made in the Git repository for a particular project it will automatically start Jenkins build for that project.
In Jenkins trigger build section I selected trigger build remotely.
In .git directory, hooks directory is there in that we have to configure post commit file.
I am confusing how to trigger a build from there (I know some part we should use curl command).
curl cmbuild.aln.com/jenkins/view/project name/job/myproject/buildwithparameters?Branch=feat-con
I have placed this command in my git server hooks directory (post commit hook).
Whenever the changes happen in repository it is running automate build.
I want to check in changeset whether in at least one java file is there the build should start.
Suppose the developers changed only xml files or property files the build should not start.
Along with xml, suppose the .java files is there the build should start.
As mentioned in “Polling must die: triggering Jenkins builds from a git hook“, you can notify Jenkins of a new commit:
As mentioned here, make sure to use the right address for your Jenkins server:
To reinforce that last point, ptha adds in the comments:
You can also use a simple post-receive hook like in “Push based builds using Jenkins and GIT“
However, this is a project-specific script, and the author mentions a way to generalize it.
The first solution is easier as it doesn’t depend on authentication or a specific project.
Basically, your build script can:
git notes) on the first callHEADof your branch candidate for build and the commit referenced by thegit notes‘build’ (git show refs/notes/build):git diff --name-only SHA_build HEAD.git notes‘build‘ toHEAD.May 2016: cwhsu points out in the comments the following possible url:
June 2016, polaretto points out in the comments: