Jenkins Build loop upon git push

I have setup a Jenkins pipeline job, for which I want only to kick off the job when changes are made to a particular directory. I added the following to Included Regions in the Polling ignores commits in a certain path

spring-boot-app/*

and the rest of the parts are pasted in as excluded Regions.

Tried with Other Additional behaviors as well

  • Polling ignores commits from certain users
  • Polling ignores commits with certain messages

Repo URL :Github Repository

To avoid the cache issue tried the following as well.

  1. Restarted the Jenkins server
  2. Created a new job

Please advise me, on where I am doing wrong. Thanks,

Hello @imtiazalijamil and welcome to this community. :wave:

Which version of Jenkins are you running? On which operating system?
Your approach looks good to me, but there might be few things to double-check and consider:

  1. Polling Configuration:
  • Ensure that the job is set up to poll for changes. In your Pipeline configuration, there should be a section for “Build Triggers” where you can enable “Poll SCM.”
  1. Included and Excluded Regions:
  • If you want to trigger the job only when changes are made in the spring-boot-app/ directory, you maybe should include this directory in the “Included Regions” field. This means you want to include spring-boot-app/ and not exclude it.
  • I would recommend leaving the “Excluded Regions” field empty unless you specifically want to exclude certain paths.
  1. Pipeline Script:
  • Ensure that your pipeline script (Jenkinsfile) includes the necessary configuration for your build steps.
  1. Polling Schedule:
  • Check your polling schedule in the Jenkins job configuration. The job will only be triggered when changes are detected during the polling interval.
  1. Repository URL:
  • Verify that the repository URL is correctly configured in your job. Ensure that it points to the correct GitHub repository and branch.
  1. Webhooks (Recommended):
  • Instead of relying on polling, consider using webhooks provided by GitHub. With webhooks, Jenkins can be triggered in near real-time whenever changes are pushed to the repository. This is a more efficient and responsive way to trigger builds when changes occur.
  1. Logs and Diagnostics:
  • Check the console output of your Jenkins job for any errors or messages related to Git polling. This could provide valuable insights into what might be going wrong.
  1. Jenkins Version:
  • Ensure that you are using a relatively recent version of Jenkins, as older versions might have limitations or issues related to Git polling and triggering jobs based on paths.