问题
I have a project in bitbucket and recently installed jenkins .
In jenkins I created a job in jenkins . from New Item
, I ticked Freestyle project
and did not add anything to the jenkins project .
in the configure section
- I added Source Code Management -> none
- Build Triggers -> Build when a change is pushed to BitBucket
In Bitbucket went to
- Project settings
- Hooks
- Select hook -> jenkins
- Add hook
and added the following values
Endpoint :- http://myaddress.com:8080
Module name : my jenkins job name
project name - empty
token - empty
so
I want to bulid my jenkins job automatically when I push code to bitbucket.
回答1:
After some research I found a good solution finally:
- 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.
Best, you don't have to create new hooks for every Jenkins project just define the separate build process or branches to be build.
回答2:
AFAIK, you need to have Git or Mercurial setup to work with BitBucket. After all, you will be making changes to your files. Please refer these links for further info on how to configure it with Jenkins.
http://felixleong.com/blog/2012/02/hooking-bitbucket-up-with-jenkins
https://confluence.atlassian.com/display/BITBUCKET/Bitbucket+101
http://blogs.steeplesoft.com/posts/2014/02/05/integrating-bitbucket-and-jenkins/
回答3:
I haven't done used Bitbucket for it. But it looks like a simple requirement and Jenkins Poll SCM feature should work for you. You can have a look here for instructions
Off-course you need to add your ssh public key in jenkins for this to work
I am not sure in method you describe what authentication mechanism Jenkins will use to checkout your repo from Bitbucket?
来源:https://stackoverflow.com/questions/25802432/build-jenkins-job-when-push-code-to-bitbucket