Skip to main content

How to create a Jenkins pipeline in multiple branches automatically?

Introduction

In the modern CI/CD setup, we may require to create a Jenkins pipeline based on the branches which are available in the SCM (Source Code Management). For example, the developer needs a Jenkins pipeline for his own feature/bugfix branch which can build, test and prepare the code coverage report. Manually creating this Jenkins pipeline for the new branches is not an effective one. So, we need an automation, which should create the new Jenkins pipeline whenever the developer creates a new branch in SCM. 

Jenkins Multibranch Pipeline

The Multibranch Pipeline allow us to automatically create a pipeline for each branch on our Source Code Management (SCM) repository with the help of Jenkinsfile.

How to setup Multibranch Pipeline in Jenkins

  1. Select New Item from Jenkins Dashboard

  2. Enter the project name in the Item name text box and select Multibranch Pipeline then click OK button.

  3. Select your version control software from the Build Source.

  4. Configure the SCM 

  5. Select the Discovery Strategy as per your need. It tells, when and which branch requires the pipeline.

  6. Click Save Button
  7. Add the Jenkins file (It contains the stages of Jenkins pipeline) into the repository branch.
  8. Click Scan Repository from Jenkins menu.

  9. Jenkins will create the pipeline for the branches which contains the Jekins file. Check the Scan Repository Logs for the results.

  10. Select the project name from Jenkins Dashboard, It will contains the list of pipelines for the branchs.

Jenkins File

The Jenkins file contains the information about the pipeline stages, It needs to be added in the SCM branches whereever we required the pipeline setup.
The sample Jenkins file is avaiable in the Github link

Comments

Popular posts from this blog

Test Driven Development

What is Test Driven Development (TDD)? TDD is a process of writing the test code before writing the functional code. In the TDD the tests are developed even before implementing the feature. At the first level the test will fail because we are not yet implemented the functional code. To make the test pass, we need to implement the functional code. TDD workflow The TDD follows the flow of "Red, Green, Refactor"     Identify the smallest behavior of the application and add the test     The test may fail     Write the functional code to make the test pass     Run the test case and make sure the tests pass     Refactor the code, if required     Repeat the process for the complete application behaviors Flow diagram for Test Driven Development (TDD)   Advantage of TDD     Early bug identification     Good understanding of code     Be...

Implementing Turn-by-Turn Navigation with the GraphHopper Routing Engine

 Introduction to Turn-by-Turn Navigation Turn-by-turn navigation is a feature that guides users through a journey step-by-step using voice or visual prompts. It is typically found in GPS navigation apps and can be used for driving, walking, and biking. When it comes to the actual implementation, turn-by-turn navigation utilizes several technologies such as GPS, maps, and routing algorithms to guide users along the best route to their destination. In this article, we will explore the implementation of turn-by-turn navigation using the GraphHopper library and OpenStreetMap data. Understanding the GraphHopper Routing Engine GraphHopper Routing Engine is an open-source routing library that allows developers to calculate efficient routes for various transportation modes, such as cars, bikes, and walking. It utilizes OpenStreetMap data to generate a routing graph, which is then used to calculate the fastest or shortest routes between two points. GraphHopper is written in Java and can be ...

K - Means (Simplest clustering algorithm)

K- Means Algorithm Introduction K- Means algorithm is an unsupervised machine learning algorithm. It is the simplest algorithm to grouping the data based on theirs attribute values. What is clustering? Clustering is the process of grouping similar elements together. As a example, we will take the salaries of the persons and grouping them as middle class, lower middle class and upper middle class. Let's assume the example data set (Persons and their salaries) Input Data set Person 1 20000 Person 2 6000 Person 3 7000 Person 4 11000 Person 5 15000 Person 6 19000 Person 7 30000 Person 8 25000 Person 9 4000 Perso   10 8000 The similar amount of salaried persons can be grouped as like below Lower Middle Class Middle Class Upper Middle Class Person 2 Person 1 Person 7 Person 3 Person 4 Person 8 Person 9 Person 5 ...