0

Is there any way to make Jenkins builds after each commit in any branch ? Because i found in my project's configuration that Jenkins run build only after detecting commits in specific branch or in the default ( eq to master in git ). PS: i'm using mercurial and Jenkins file. Should i change project type ( new item type in Jenkins ) or are there any modifications in configs.

  • Does this answer your question? [Let Jenkins build project from a Mercurial commit](https://stackoverflow.com/questions/19299120/let-jenkins-build-project-from-a-mercurial-commit) – StayOnTarget Dec 01 '20 at 14:57

2 Answers2

1

There are two things that you should check for this (I haven't work with Mercurial)

  • Does Mercurial has the option to create webhooks?
  • There is a jenkins plugin for Mercurial? (I think there is)

You must configure on the mercurial site the webhook pointing to Jenkins and give the point to the job you want to run, and on which events does it will fire. On the Jenkins side you must configure on the job who it will behave.

For example, with GitLab, the plugin has an option configured on the "Build Trigger" section where you configure the events and the branches that fires the job. In GitLab, in the repository you create the webhook, that is only a URL pointing to the Jenkins job.

mndrye
  • 489
  • 2
  • 7
  • Mercurial and Git have the same configuration. I have added plugins and webhooks and it works for me. Now Jenkins detects any push in a specific branch. But i want it to detect changes not only for specific branch but for all branches. For example, with Git you have to write "*" in the revision field but it didn't work with Mercurial. – SAID Med Bechir Dec 01 '20 at 07:44
  • 1
    Try configure your Jenkins Job this way: in the Source Code Management tab, check if the branch is blank (meaning any) or you have a branch there. Also you may have to check on the Mercurial side if you put any branch there – mndrye Dec 01 '20 at 10:47
  • i did, and for mercurial configurations if that field is empty the default value will be the default branch ( master in Git ). – SAID Med Bechir Dec 01 '20 at 11:12
  • 1
    Check in mercurial's documentation, but in GitLab you can use * for all branches – mndrye Dec 01 '20 at 11:28
  • That's what i was asking for. I would to know if there is something similar to Git config but i didn't find a solution for my problem. – SAID Med Bechir Dec 01 '20 at 11:31
  • I have never used mercurial, so I can't help any further. Maybe check this https://stackoverflow.com/questions/19299120/let-jenkins-build-project-from-a-mercurial-commit – mndrye Dec 01 '20 at 11:46
0

I got this solution and it worked for me. with Mercurial, we can use the "tip" keyword.The tip revision is the most recent changeset in the repository. It is the most recently changed head.