my jenkins test job console execute shell look like this;
#!/bin/bash
echo $(id)
npm -v
when I build this job the console output shown as;
uid=497(jenkins) gid=495(jenkins) groups=495(jenkins)
3.10.10
when I ssh into jenkins ec2 machine and then switch to jenkins user and run the command npm -v I got the different version of npm.
I suspect jenkins console execute shell run as root user shell where it picked up the npm version of root user.
when I run whoami and which npm I got the results on jenkins console as jenkins and /usr/bin/npm respectively, but while on jenkins ec2 instance when I run these commands on jenkins user shell I got the results as jenkins and ~/.nvm/versions/node/v8.10.0/bin/npm. please assist me to understand why I got two different results
Please assist. I appreciate your time
Related
When we are trying to execute yo jhipster --force --skip-git --skip-install from jenkins shell job,
we are receiving the below output:
Easy with the sudo. Yeoman is the master around here.
since yo is a user command, there is no need to execute it with root permissions. if you're having permission errors when using yo without sudo, please spend a few minutes learning more about how your system should work and make any necessary repairs.
Yo is being installed in the server using docker file with the command RUN sh -c 'yo#3.1.1 --unsafe-perm=true --allow-root'
previously we were not facing this issue with the use of yo.
the jenkins shell screenshot
I have an npm package which is installed globally. If I call it from terminal using global package name from any directory it runs perfectly fine. If I add it in crontab it does not run. It runs from crontab only when I go the directory and call npm start. I want to run it using only a single word command on crontab. Please help.
$ appName //runs fine from any directory
$ cd path/to/npm/package; $ npm start //runs fine
crontab
#reboot appName & #does not work
#reboot npm start -prefix /path/to/npm/package & #works fine
firstly i would advise you to verify whether you are using crontab or cron, since they might behave differently.
secondly, verify the foolowing:
cron job is executed on behalf of the user which successfully able to run the global package. i.e. eliminate user permissions
cron job might need to login to the user shell if you defined some stuff in the user environment to run the global package as you expect
So I have a Jenkins CI setup on an EC2 server. I have nodejs and npm installed. Weirdly, Jenkins can access them via the command line if I do something like:
sudo -u jenkins node -v
However, Jenkins cannot access them inside an actual build runtime, and I get the following errors:
npm: command not found
pm2: command not found
npm is definitely installed, and ec2-user/root users can access it. What PATH do I have to change so that Jenkins can access it too?
I think that if you use the nodejs plugin it will be easier to manage your node and npm in this box. Also, this plugin allows installing some global modules that possibly you will need to build your project:
https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
I have installed nodejs, npm, lineman, jenkins, and phantomjs on red hat.
I am trying to run a jenkins job that just runs lineman spec-ci to run my test-em tests. When I run this command as the jenkins user on the terminal, it runs. Unfortunately, when I run this command as a job in jenkins, it fails:
node: error while loading shared libraries: libhttp_parser.so.2: cannot open shared object file: No such file or directory
This error comes up even if I try to run npm install with the jenkins job.
The jenkins service is running under the user jenkins and if I run whoami during the jenkins build it outputs jenkins.
Any idea why I can run npm and lineman commands as the jenkins user but it fails when run as a job?
I ended up running printenv and found a variable associated with libraries. I added that variable to jenkins -> configure -> global properties.
I am trying to run protractor on windows from the command line.
If I directly type the command:
webdriver-manager start
It works great.
However, from within jenkins, it keeps throwing:
'webdriver-manager' is not recognized as an internal or external command,
operable program or batch file.
My env vars seems ok, since the java and npm works fine from Jenkins.
Any idea?
As it turned out I simply forgot putting the C:\Users\USERNAME\AppData\Roaming\npm folder on the System variables and only configured it as my user path.
See elgalu's answer for your next problem though...
Install Protractor globally in the Jenkins machine, for this you may need to ssh into the Jenkins machine that run the tests:
ssh your-jenkins-server
npm -g install protractor
# update webdriver in the Jenkins machine
webdriver-manager update
# test it works
webdriver-manager start
Once you have that setup and running your next problem will probably be running Protractor headless unless your Jenkins machine has a display available and an installed windows manager like Ubuntu Desktop.