User Tools

Site Tools


toolsandtechnologies:jenkins_2_feature_builds

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
toolsandtechnologies:jenkins_2_feature_builds [2018/05/22 12:34] – [New Builds for New Branches and Build on new Commits - Bitbucket Webhook] ccarewtoolsandtechnologies:jenkins_2_feature_builds [2021/06/25 10:09] (current) – external edit 127.0.0.1
Line 1: Line 1:
 +====== Jenkins 2 - Creating Builds per Features Branch/Commit Automatically ======
 + --- //[[colm.carew@errigal.com|Colm Carew]] 2018/05/22 04:10//
 +===== Make Jenkins Publicly Accessible  =====
 +**This can be skipped if Jenkins is already publicly accessible.**
 +
 +This is very networking focused so if it is not already setup, get someone to help/the networking person to do it.
 +
 +In most cases you should just be able to port forward port 8080 directly to Jenkins 8080, however if the Public IP you are using already has an 8080 exposed to a different machine you will need a customer service, a policy to allow the service and finally assign the service (via VIP) from the Public IP to the Jenkins server
 +
 +  - Find where you can make a custom service (depends on Router Firmware but may be in Policy->Policy Elements->Services->Custom)
 +  - If one is not there for your desired function, say to forward port 9090 from external source to port 8080 of internal server then create a new one
 +  - In most cases you will want TCP, source Port Low and High should be the same, in this case 9090 and destination port should be the same for low and high so 8080
 +  - Give the service a good name and save it
 +  - Find policies (Policy->Policies) and either edit an Untrust to Trust or make a new Untrust to Trust so your service is allowed from the addresses you want and to the address you want
 +  - Find the VIP interface (Network->Interfaces->VIP) and create a new entry using the service you created from the source port (9090) and the server you want the port forward to
 +
 +===== Generating Builds Per Branch in Jenkins =====
 +Some plugins will need to be installed for this, mainly the Bitbucket Plugin and Pipeline: Multibranch Plugin - these may already be installed.
 +
 +  - Navigate to where you want the folder which will contain all the Jenkins builds for the projects
 +  - Click New Item
 +  - Give it a name
 +  - Ensure Multibranch Pipeline is selected
 +  - Click OK
 +  - Give it a display name like APPLICATION-feature-branches
 +  - In Branch Source choose Bitbucket and select the correct credentials
 +  - Set the owner to be 'errigal' and wait for the repository list to populate
 +  - Select the Repo you want to have multibranch builds of
 +  - Auto Discovery should populate, but remove the Pull Request discovery at it should be enough to test on a per commit level
 +  - Discover Branches should be set to All branches
 +  - For Property Strategy click 'Named Branches get different properties'
 +  - Add exceptions that you do not want to be built by this process (master, dev, REL-* for example) and ensure they have the property 'Suppress Automatic SCM Triggering'
 +  - Build Configuration should be Jenkins Files
 +  - Orphaned Item Strategy should have Max # of old items to keep, set to 1
 +  - That's it, hit save and the process should go off and discover all branches for the project and build them
 +
 +===== New Builds for New Branches and Build on new Commits - Bitbucket Webhook =====
 +This is the reason why we need Jenkins to be publicly accessible, so Bitbucket can send Webhooks to Jenkins and cause the builds to happen as well as show in Bitbucket if a commit build passed/failed/in progress.
 +
 +  - Go to the Bitbucket Project
 +  - Go to settings
 +  - Click Webhooks
 +  - Add a new Webhook with the name Jenkins, URL should be http://65.74.172.39:9090/bitbucket-scmsource-hook/notify or in more general terms :  https://THE_JENKINS/bitbucket-scmsource-hook/notify, status should be active, SSL/TLS should be skip if we are running over HTTP, Triggers should be repository push
 +  - Click save 
 +  - Create a new branch (even if it is a dummy), make a small change and push, see if a new build is created and starts running
 +
 +
 +
 +
 +
 +