User Tools

Site Tools


Writing /app/www/public/data/meta/toolsandtechnologies/jenkins_2_feature_builds.meta failed
toolsandtechnologies:jenkins_2_feature_builds

Jenkins 2 - Creating Builds per Features Branch/Commit Automatically

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

  1. Find where you can make a custom service (depends on Router Firmware but may be in Policy→Policy Elements→Services→Custom)
  2. 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
  3. 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
  4. Give the service a good name and save it
  5. 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
  6. 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.

  1. Navigate to where you want the folder which will contain all the Jenkins builds for the projects
  2. Click New Item
  3. Give it a name
  4. Ensure Multibranch Pipeline is selected
  5. Click OK
  6. Give it a display name like APPLICATION-feature-branches
  7. In Branch Source choose Bitbucket and select the correct credentials
  8. Set the owner to be 'errigal' and wait for the repository list to populate
  9. Select the Repo you want to have multibranch builds of
  10. Auto Discovery should populate, but remove the Pull Request discovery at it should be enough to test on a per commit level
  11. Discover Branches should be set to All branches
  12. For Property Strategy click 'Named Branches get different properties'
  13. 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'
  14. Build Configuration should be Jenkins Files
  15. Orphaned Item Strategy should have Max # of old items to keep, set to 1
  16. 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.

  1. Go to the Bitbucket Project
  2. Go to settings
  3. Click Webhooks
  4. 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
  5. Click save
  6. 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
toolsandtechnologies/jenkins_2_feature_builds.txt · Last modified: 2021/06/25 10:09 by 127.0.0.1