Background:
We have node version 8 installed and is working fine in a Jenkins alpine based docker image (running in AWS ECS). The node 8 was installed in the jenkins-alpine docker image.
Then, there came another requirement to install node js Jenkins plugin, so that custom version can be installed and applied as needed using global tools configuration, We installed nodejs 10 as shown in the image below:
Nodejs Plugin failed to run in jenkins
I then tried using the jenkins nodejs 10 plugin in jenkins pipeline as follows:
#!groovy
pipeline {
options {
buildDiscarder(logRotator(daysToKeepStr: '5'))
timeout(time: 5, unit: 'MINUTES')
ansiColor('xterm')
}
agent {
label 'jenkins-slave'
}
stages {
stage('Nodejs test') {
steps {
nodejs('NodeJS 10.19.0') {
sh "which node; which npm"
sh "ls -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node"
sh "node -v"
}
}
}
}
}
}
The jenkins job failed as it could not find node even though it did exist and was executable:
11:00:31 + which node
11:00:31 /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node
11:00:31 + which npm
11:00:31 /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/npm
[Pipeline] sh
11:00:31 + ls -l /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node
11:00:31 -rwxrwxr-x 1 jenkins jenkins 41122344 Feb 5 23:36 /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node
11:00:32 + /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node -v
11:00:32 /var/jenkins_home/workspace/test-jerald-nodejs-plugin@tmp/durable-55482f4f/script.sh: line 1: /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: not found
Tests inside jenkins slave docker container
I tried executing the node version command directly in the jenkins slave docker container, however, output was same. Then I googled and referred the following thread which mentioned that this is because of the missing libraries needed by nodejs. Jenkins NodeJSPlugin node command not found
Following was the initial output on finding the shared libraries of nodejs from jenkins plugin
bash-4.4$ ldd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node
/lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7fcbe2d29000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7fcbe2d15000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7fcbe2e7e000)
Error loading shared library ld-linux-x86-64.so.2: No such file or directory (needed by /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node)
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: gnu_get_libc_version: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: __register_atfork: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: setcontext: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: makecontext: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: backtrace: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: getcontext: symbol not found
I then installed the missing libraries with the following command:
apk add libc6-compat gcompat
After installing the missing libraries, there was no error related to missing libraries, however there is still errors with "symbol not found" and node was still not executable.
bash-4.4# ldd /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node
/lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
libdl.so.2 => /lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
librt.so.1 => /lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f0e697a1000)
libm.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f0e6978d000)
libpthread.so.0 => /lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
libc.so.6 => /lib64/ld-linux-x86-64.so.2 (0x7f0e698f6000)
ld-linux-x86-64.so.2 => /lib/ld-linux-x86-64.so.2 (0x7f0e69787000)
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: gnu_get_libc_version: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: __register_atfork: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: setcontext: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: makecontext: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: backtrace: symbol not found
Error relocating /var/jenkins_home/tools/jenkins.plugins.nodejs.tools.NodeJSInstallation/NodeJS_10.19.0/bin/node: getcontext: symbol not found
bash-4.4#
I also checked the shared libraries of existing node v8, and it had no issues:
bash-4.4# which node
/usr/local/bin/node
bash-4.4# ldd /usr/local/bin/node
/lib/ld-musl-x86_64.so.1 (0x7f1e07118000)
libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0x7f1e0539f000)
libgcc_s.so.1 => /usr/lib/libgcc_s.so.1 (0x7f1e0538b000)
libc.musl-x86_64.so.1 => /lib/ld-musl-x86_64.so.1 (0x7f1e07118000)
bash-4.4# /usr/local/bin/node -v
v8.11.3
So could anyone assist me on getting the Jenkins nodejs plugin to work?