'How to go about seeing the branch name of builds in the build history view of Jenkins?

I installed the Feature Branch Notifier Plugin in my instance of Jenkins.

I have checked the "Show full length branch name in the build history view" checkbox at jenkins:8080/configure

I am expecting to see the branch names in build history view, but even after restarting Jenkins I am not seeing the branch names in the build history, as can be seen in the enclosed image.

enter image description here

The project issue queue lists no open issues, and when I try to log in to post an issue, I get the message "Proxy Error - The proxy server received an invalid response from an upstream server. The proxy server could not handle the request POST /account/doSignup. Reason: Error reading from remote server Apache/2.2.14 (Ubuntu) Server at jenkins-ci.org Port 443"

Does anyone know how to go about seeing the branch name of builds in the build history view of Jenkins? Thanks!

Albert.



Solution 1:[1]

You can use Build Name Setter Plugin, and set Set Build Name something like #${BUILD_NUMBER} - ${GIT_BRANCH}.

Build Name Setter Plugin

Solution 2:[2]

Build-Name-setter-plugin no longer works. I tried on 2.319.1, and the setting never appears in the pipline.

The solution I found is to use the build environment variables to apply to your display name for the build in a step script.

Adjust your Jenkinsfile to pull the branch name as a environmental variable (I am using CURRENT_BRANCH_NAME). Then I created a new stage / step, that runs before any other, and ran a script to adjust the displayname there:

pipeline {
agent {any}
    environment {
        CURRENT_BRANCH_NAME = "${GIT_BRANCH.split('/').size() > 1 ? GIT_BRANCH.split('/')[1..-1].join('/') : GIT_BRANCH}"
    }
    stages {
        stage('Set branch name') {
            steps {
                script{
                    currentBuild.displayName = "#"+currentBuild.number+": "+CURRENT_BRANCH_NAME
                }
            }
        }
     stages {
            stage('Ok now start doing testing') {
                steps {
                    sh '''#!/bin/bash
                          echo "Im gona test everything"
                    '''

                }
            }
        }
}

Now when your Jenkins test starts to build, the name will update once the step is complete.

Note: this solution was tested in a single pipeline (not multi-pipeline), and was for a SCM repo integration.

Sources:

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Victor Basso
Solution 2 Dave