Jenkins build after mercurial commit

后端 未结 3 706
悲哀的现实
悲哀的现实 2021-01-02 23:38

I\'ve been working on this project for about a week now and I\'ve been searching for 2 days without any clear explanation online. For a school assignment, we need to set up

相关标签:
3条回答
  • 2021-01-02 23:45

    The most efficient way to trigger builds on Jenkins after someone pushed to your repo is using the changegroup hook in mecurial.

    Jenkins on the other hand allows builds to be triggered remotely by calling the URL of your job with a special token. This trigger with the corresponding token has to be configured in your job on Jenkins:

    Build trigger configuration

    The mercurial hook that will be put in the repos .hg/hgrc file can be defined like:

    [hooks]
    changegroup = curl --silent http://your.jenkins.server.url/jenkins/job/<YOURJOBNAMEHERE>/build?token=Foo
    

    This hook uses the curl command line tool to call the URL of your jenkins job with the defined token that allows to trigger the job remotely. Curl has to be installed on your linux box of course.

    0 讨论(0)
  • It sounds like your professor wants Jenkins to poll the Mercurial repository for changes ("triggered every 1 minute"). When you set up your Jenkins job, the section called "Build Triggers" will have a poll option. That's the one you want.

    A better solution would be to have Mercurial tell Jenkins about changes, since polling is generally a bad idea (even if you don't check anything in for days, Jenkins still asks every minute if anything has changed). You can look at the book for examples on how to write Mercurial hooks, or you can use the Python script I wrote.

    0 讨论(0)
  • 2021-01-02 23:57

    To trigger Jenkins builds when pushing to a Mercurial repository on Bitbucket you can go to administration (click the cog wheel) for your repository and choose Services. There you can define a Jenkins service with four parameters:

    1. Endpoint: the URL of the Jenkins server.
      • For a secure Jenkins server you need to specify a username and an api token. The api token is generated by Jenkins for the specific user, on the "Manage Users" / "Configure" page.
    2. Module name: optional parameter, to trigger builds selectively depending on what has been pushed
    3. Project name: the name of the Jenkins job
    4. Token: optional parameter, the same as the Authentication Token defined on the Jenkins job when you select "Trigger builds remotely (e.g., from scripts)"

    (I suppose that this is just a gui way to define a "changegroup hook" as mentioned by James in his reply from 7 November 2012.)

    0 讨论(0)
提交回复
热议问题