Foreword
When we have submitted the code to the code repository, we hope to build automatically trigger tasks, this demand can "build trigger" is achieved by jenkins's.
Generally companies have their own local code reference as gitlab, I'm here to github, for example, are almost set.
Preparing the environment:
1.Jenkins GitHub Plugin installed plug-
2.Jenkins services outside the network can access
System Settings
jenkins system management - System Settings -Git Hub plug-in, opening the Advanced Options
Check specify an alternative Hook URL for the Github, address here: http://ip:端口/github-webhook/
Remember, behind the same set of addresses on github webhook
webhook
Open github repository page -Settings
Add webhook
Edit webhook, must be noted Payload URL to the external network can access otherwise inaccessible to GitHub Jenkins
- Payload URL input
http://ip:端口/github-webhook/
, consistent with Hook URL address set on the top jenkins - Which events would you like to trigger this webhook select only push past when the code triggers:? Just the push event.
If you want to choose another trigger, you can point to open "Let me select individual events."
Click the Add webhook
button to submit successful.
Construction of the flip-flop
Set inside the building job trigger check: GitHub hook trigger for GITScm polling
Trigger building
Next to update the code, push to github repository, after pushing past, the job will automatically trigger jenkins task while viewing the webhook github page, you will see the success of the trigger