env.BUILD_URL is null

The Jenkins version we are using is 2.361.4. It is running in a Kubernetes cluster version 1.23, and is installed via Helm. The Kubernetes plugin we are running right now is 3734.v562b_b_a_627ea_c

The issue is we have a slack setup where anytime a build job succeeded or failed, a message would be displayed along with using env.BUILD_URL, which use to output something like

https://my-jenkins.com/job/prod/thisjob/11/ succeeded

However, now the message looks like

null succeeded

and this seems to have occurred after installing the pipeline utility steps plugin, which in turn updated some other plugins, but I don’t have a list of what updates occurred and I don’t quite believe installing that plugin would cause this issue but mentioning it for completeness.

I’ve examined the JENKINS_URL setting in the Configure System section and it’s still the same registered domain as before.

Printing out all environment variables in the job, I’m noticing some lines like

JOB_DISPLAY_URL=http://unconfigured-jenkins-location/job/test/job/test-pipeline-vince/display/redirect
JENKINS_URL=http://jenkins.jenkins.svc.cluster.local:443/
BUILD_NUMBER=95
JOB_NAME=test/test-pipeline

I’ve looked at the Kubernetes Plugin documentation and any stackoverflow posts, but can’t seem to find the right question that explains this problem.

Has anyone encountered this issue or know what to look for on why env.BUILD_URL would suddenly be null?

SOLVED:

I found this github post and basically just going into the Configure System and choosing Save even without changing anything fixed the issue.

https://github.com/opendevstack/ods-jenkins-shared-library/issues/40

The environment URL JENKINS_URL shows the correct domain as before and the BUILD_URL shows up properly now.

The cause is unknown, maybe something during the update of plugins, but this fix did it.

2 Likes

Thanks a lot for your feedback @vinfang :+1:

1 Like

Just a follow up on this, we’re on Jenkins 2.401.1 on Kubernetes 1.24, Kubernetes plugin Version 4029.v5712230ccb_f8, and we occasionally see this happen even when the plugins haven’t been updated recently.

Same fix still works, but was hoping if someone could provide insight or point to where in the Jenkins logs I could get more info on why this happens randomly. There doesn’t seem to be any pattern on why this happens and it’s rare, maybe like 1 once in 2 or 3 months the build URL becomes NULL even though the system configuration settings have not changed at all.