Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8644257
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T12:15:00+00:00 2026-06-12T12:15:00+00:00

How to trigger a build remotely from Jenkins? How to configure Git post commit

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T12:15:01+00:00Added an answer on June 12, 2026 at 12:15 pm

    As mentioned in “Polling must die: triggering Jenkins builds from a git hook“, you can notify Jenkins of a new commit:

    With the latest Git plugin 1.1.14 (that I just release now), you can now do this more >easily by simply executing the following command:

    curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>
    

    This will scan all the jobs that’s configured to check out the specified URL, and if they are also configured with polling, it’ll immediately trigger the polling (and if that finds a change worth a build, a build will be triggered in turn.)

    This allows a script to remain the same when jobs come and go in Jenkins.
    Or if you have multiple repositories under a single repository host application (such as Gitosis), you can share a single post-receive hook script with all the repositories. Finally, this URL doesn’t require authentication even for secured Jenkins, because the server doesn’t directly use anything that the client is sending. It runs polling to verify that there is a change, before it actually starts a build.

    As mentioned here, make sure to use the right address for your Jenkins server:

    since we’re running Jenkins as standalone Webserver on port 8080 the URL should have been without the /jenkins, like this:

    http://jenkins:8080/git/notifyCommit?url=git@gitserver:tools/common.git
    

    To reinforce that last point, ptha adds in the comments:

    It may be obvious, but I had issues with:

    curl http://yourserver/jenkins/git/notifyCommit?url=<URL of the Git repository>. 
    

    The url parameter should match exactly what you have in Repository URL of your Jenkins job.
    When copying examples I left out the protocol, in our case ssh://, and it didn’t work.


    You can also use a simple post-receive hook like in “Push based builds using Jenkins and GIT“

    #!/bin/bash
    /usr/bin/curl --user USERNAME:PASS -s \
    
    http://jenkinsci/job/PROJECTNAME/build?token=1qaz2wsx
    

    Configure your Jenkins job to be able to “Trigger builds remotely” and use an authentication token (1qaz2wsx in this example).

    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.


    I want to check in change set whether at least one java file is there the build should start.
    Suppose the developers changed only XML files or property files, then the build should not start.

    Basically, your build script can:

    • put a ‘build’ notes (see git notes) on the first call
    • on the subsequent calls, grab the list of commits between HEAD of your branch candidate for build and the commit referenced by the git notes ‘build’ (git show refs/notes/build): git diff --name-only SHA_build HEAD.
    • your script can parse that list and decide if it needs to go on with the build.
    • in any case, create/move your git notes ‘build‘ to HEAD.

    May 2016: cwhsu points out in the comments the following possible url:

    you could just use curl --user USER:PWD http://JENKINS_SERVER/job/JOB_NAME/build?token=YOUR_TOKEN if you set trigger config in your item

    http://i.imgur.com/IolrOOj.png


    June 2016, polaretto points out in the comments:

    I wanted to add that with just a little of shell scripting you can avoid manual url configuration, especially if you have many repositories under a common directory.
    For example I used these parameter expansions to get the repo name

    repository=${PWD%/hooks}; 
    repository=${repository##*/} 
    

    and then use it like:

    curl $JENKINS_URL/git/notifyCommit?url=$GIT_URL/$repository
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a git post receive hook that will trigger a build on my
How do I tell Jenkins/Hudson to trigger a build only for changes on a
I am currently using PycURL to trigger a build in Jenkins, by posting to
How would you manually trigger additional team builds from a team build? For example,
I have job A which trigger build on the basis of commit, after completion
Is it possible to trigger a Hudson/Jenkins build only when a certain string appears
I am trying to build an app in which I want to trigger a
Hi friends can any one suggest me how to trigger a svn android build
I want to trigger a long running background process (coded as a service) from
Bamboo CI has a build in feature of having the subversion program trigger a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.