1

I am in the middle of trying to implement a build/deploy job in Jenkins by which the latest version of source code is pulled from git, built and then deployed to GCP. So far I am able to retrieve the lastest code from GIT but have run into issues when tyring to build. The application being built/deployed is an Angular 7 web site using npm for package management. So the normal steps would be to run npm install to make sure the packages are installed and then ng build -- prod to build the app.

My issue is that the version of npm/nodejs in the master node is out of date and not compatable with Angular 7. Even just trying the command to gert the current ng version fails:

+ /usr/bin/ng v
You are running version v8.1.4 of Node.js, which is not supported by Angular CLI v6.
The official Node.js version that is supported is 8.9 and greater.

I added a call to npm version to check the npm version is is trying to use:

+ echo current user
current user
+ whoami
jenkins
+ npm -v
5.0.3

To investigate the issue I used putty to remote onto the jenkins box and ran npm -v and ng v to see what is installed and get:

jenkins@****-int1:~$ npm -v
6.5.0-next.0

Which is different to that reported by npm -v in the shell script.

jenkins@****:~$ ng v

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/


Angular CLI: 7.1.4
Node: 11.6.0
OS: linux x64
Angular:
...

Package                      Version
------------------------------------------------------
@angular-devkit/architect    0.11.4
@angular-devkit/core         7.1.4
@angular-devkit/schematics   7.1.4
@schematics/angular          7.1.4
@schematics/update           0.11.4
rxjs                         6.3.3
typescript                   3.1.6

So it should have nodejs 11.6, I ran node -v to double check:

jenkins@****:~$ node -v
v11.6.0

BUT if I run nodejs -v I get:

jenkins@****:~$ nodejs -v
v8.1.4

I thought that node and nodejs were the same thing? so why would I have two different versions installed and how to fix this?

To double check what my Jenkins script is using I added a call to node -v in the script and as expected it reports the older version:

+ node -v
v8.1.4

I'm not a DevOps person, I'm C# back end developer who's been lumbered with sorting this out due staff changes. I know very little about Linux, Jenkins or this stuff in general.

I tried to update the node installation via the Jenkins Shell script using

sudo npm cache clean -f
sudo npm install -g n
sudo n stable

But these were refused due to access rights (no sudo pwd I presume) and I don't know if that would've fixed the issue anyway.

Any help?

1
  • I think the difference in node versions you can see is because the node is installed to Jenkins host using 1. Linux terminal and 2. node plugin in Jenkins. Maybe, try to update the Jenkins plugin for node or Angularjs. Beware of making changes in the production server carefully.
    – KlwntSingh
    Commented Jan 6, 2019 at 23:03

1 Answer 1

1

I would have a look at the Tool Auto-Installation which allows Jenkins to install the tooling you need.

Lets you configure tools so that agents will install them on demand whenever running a job that needs them. This could be especially useful when running a large farm of agents in a cloud which all start with a minimal operating system configuration.

Speaking of that also checkout the NodeJS Plugin which

Provides NodeJS auto-installer, allowing to create as many NodeJS installations "profiles" as you want. The auto-installer will automatically install a given version of NodeJS, on every jenkins slave where it will be needed Allows to install globally some npm packages inside each installations, these npm packages will be made available to the PATH

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.