Jenkins appends to LOCALVERSION string for every build

Hello,

I am having an issue with a Jenkins build which I am not able to resolve.

I am currently having a setup in Jenkins where I have VM where Jenkins connects via ssh and performs some operations to completely build a linux kernel for an NVIDIA Jetson chip.

Whenever I use the same build steps locally in the VM, the build works as it is supposed to. However, when using jenkins, the build does not work properly.

Due to the nature of the build process, I do need to set the environment variable LOCALVERSION=-tegra in order to build correctly the kernel. After debugging, I have figured out that jenkins is adding an extra string to the end of the kernel version for every build, and this behaviour is unwanted.

Does anybody know how to make jenkins not to append that string?

Thank you!

It might be useful to share your build script here. There are a lot of “it depends” here that might be cleared up.

For example, a shared pipeline script that has been told to always add to that variable. An agent configuration that does similar.

Hi,

This is the shell script that I am executing.

#!/bin/bash
printf "\n##################################################\n"
printf "Build the Kernel + Drivers \n"
printf "##################################################\n\n"

printf "Setting input kernel src and output paths\n"
export REPO_KERNEL_PATH=$WORKSPACE/AS_Jetson_Kernel
export KERNEL_SOURCE=$REPO_KERNEL_PATH/kernel/kernel-4.9
export TEGRA_KERNEL_OUT=$REPO_KERNEL_PATH/kernel_output

printf "Setting compiler\n"
cd $REPO_KERNEL_PATH
export TOOLCHAIN_SUBPATH=toolchain_gcc_7_3_1
mkdir $TOOLCHAIN_SUBPATH
# gcc 7_3_1
tar -xvf gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu.tar.xz -C $TOOLCHAIN_SUBPATH
export CROSS_COMPILE=$REPO_KERNEL_PATH/$TOOLCHAIN_SUBPATH/gcc-linaro-7.3.1-2018.05-x86_64_aarch64-linux-gnu/bin/aarch64-linux-gnu-
export LOCALVERSION=-tegra

printf "Compiling kernel with cross-compiling\n"
cd $KERNEL_SOURCE
mkdir -p $TEGRA_KERNEL_OUT
make ARCH=arm64 O=$TEGRA_KERNEL_OUT tegra_defconfig
make ARCH=arm64 O=$TEGRA_KERNEL_OUT -j$(nproc)

Also, see what uname -r command throws at in the target:

gpu@vdu:~$ uname -r
4.9.253-tegra-ab27

That ab27 is unwanted. It changes every build, and it matches the build number

Found the solution. Jenkins environment variable was messing with the kernel release string. You can change this behaviour in the main kernel makefile:

# KERNELRELEASE can change from a few different places, meaning version.h
# needs to be updated, so this check is forced on all builds

uts_len := 64
ifneq (,$(BUILD_NUMBER))
	UTS_RELEASE=$(KERNELRELEASE)-ab$(BUILD_NUMBER)
else
	UTS_RELEASE=$(KERNELRELEASE)
endif
1 Like

Thanks a lot for the feedback. :+1: