How do I get Jenkins to build on push to a BitBucket git repository?

后端 未结 7 1147
一个人的身影
一个人的身影 2020-12-12 18:21

I have a git repository hosted on BitBucket, and have set up SSH authentication between the repository and my Jenkins server. I can build on Jenkins manually, but cannot ge

7条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2020-12-12 18:35

    Due to the Jenkins Hook of Bitbucket is not working at all for me and I have different Jenkins projects for different branches I had come to this solution:

    • Install Bitbucket Plugin at your Jenkins
    • Add a normal Post as Hook to your Bitbucket repository (Settings -> Hooks) and use following url:

    https://YOUR.JENKINS.SERVER:PORT/bitbucket-hook/

    and if you have setup authentication on jenkins then URL must be like

    https://USERNAME:PASSWORD@YOUR.JENKINS.SERVER:PORT/bitbucket-hook/

    • Configure your Jenkins project as follows:
    • under build trigger enable Build when a change is pushed to BitBucket
    • under Source Code Management select GIT; enter your credentials and define Branches to build (like **feature/*)

    By this way I have three build projects, one for all features, one for develop and one for release branch. Make sure to include the slash ('/') on the end of the URL or the hook won't work.

    And best of it, you don't have to ad new hooks for new Jenkins projects.

提交回复
热议问题