7

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.

alberto56
  • 2,997
  • 3
  • 28
  • 47

2 Answers2

9

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

Build Name Setter Plugin

Victor Basso
  • 5,556
  • 5
  • 42
  • 60
Michael Hsu
  • 119
  • 1
  • 7
  • Can you also set the branch name for the jobs that are waiting in the queue? – Noa Oct 22 '18 at 19:44
  • I have tried everything, this plugin will not work on 2.319. The documentation is lacking and does not detail if there are any requirements for this to work. "Set build name" refuses to appear in the job settings. – Dave Jan 31 '22 at 14:49
0

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:

Dave
  • 727
  • 1
  • 9
  • 20