jenkins hook not working - jenkins bitbucket

ⅰ亾dé卋堺 提交于 2019-12-07 02:27:05

问题


Hi i am using jenkins and bitbucket , i want to trigger a build in jenkins when ever i commit any thing to bitbucket repository .

in jenkins

  • i created a project called test_1
  • in configure section Build Triggers part i ticked Trigger builds remotely
  • i added a token TEST_TOKEN

when i type this in my browser url and execute the jenkins build is triggered

http://test.com:8080/job/test_1//build?token=TEST_TOKEN 

In bitbucket

i added a jenkins hook

  • Endpoint : http://test.com:8080/job/test_1//build?token=TEST_TOKEN
  • Module name - empty
  • Project name - test_1
  • Token - empty

then commited some code to bitbucket via git , The jenkins build not running , seems that the trigger is not running . :/ how to solve this problem . please help me . thanks in advance :)


回答1:


I had the same problem. @fmitchell is correct with his suggestions for these fields. But it didn't work for me.

I use a normal POST Hook instead where I provide the whole URL:

http://USER_NAME:USER_TOKEN@YOUR.JENKINS.URL.COM:YOUR_PORT/job/YOUR_PROJECT_NAME/build?token=some_token_from_jenkins

eg: http://bob.miller@jenkins.example.com:8080/job/test_1/build?token=TEST_TOKEN

It seems to be that Bitbuckt is missing the last parameter "build" in its created URL, but I can't tell for sure.

------Update------

I found a better solution, where you don't only trigger your build but also be able do build different branches by different Jenkins projects:

  • 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

  • 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.

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




回答2:


It should be:

Endpoint : http://test.com:8080/
Module name:
Project name: test_1
Token: TEST_TOKEN



来源:https://stackoverflow.com/questions/25845593/jenkins-hook-not-working-jenkins-bitbucket

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!