Multibranch Pipeline in Jenkins

Step 1: Add GitHub Credentials

  1. Navigate to DashboardManage JenkinsCredentials.

  2. Click Global credentials (or the appropriate domain).

  3. Click Add Credentials.

  4. Select Username and Password:

    • Username: GitHub username

    • Password: GitHub personal access token

  5. Click Save.


Step 2: Create a Multibranch Pipeline

  1. Go to Dashboard → Click on New Item.

  2. Select Multibranch Pipeline.

  3. Provide the following details:

    • Display Name: <Project Name>

    • Description: <Short Description (Optional)>


Step 3: Configure Branch Sources

  1. Under Branch Sources, click Add source and select GitHub.

  2. Set the following options:

    • Credentials: Select the previously added GitHub credentials.

    • Repository HTTPS URL: Copy and paste the project repository URL.

    • Click Validate to check the connection.


Step 4: Configure Behaviors

  1. Discover Branches (Strategy): All branches.

  2. Discover Pull Requests from Origin (Strategy): The current pull revision.

  3. Discover Pull Requests from Forks (Strategy): The current pull revision.

  4. Trust: Everyone.


Step 5: Add Filters

  1. Click Add → Select Filter by name (with wildcards).

  2. Set Include: <Branch Name>*.


Step 6: Configure Build Settings

  1. Property Strategy: All branches get the same properties.

  2. Build Configuration Mode: By Jenkinsfile.

  3. Script Path: Jenkinsfile (Specify the location of the pipeline script in the repository).

  4. Keep other options as default.


Step 7: Save and Run the Pipeline

  1. Click Save.

  2. The pipeline will automatically scan for branches and pull requests matching the filters.

  3. It will trigger builds based on changes in the repository.