Search code examples
jenkinskarma-runnerkarma-jasminekarma-coverage

How to set CHROME_BIN in jenkins when deploying to production for angular test coverage


I have a maven project that I deployed to a jenkins server, and I would like to run code coverage report there for my AngularJS code. I have jenkins installed a service on my local machine, and have my tests running there when I build my project.

The tests are passing fine, but when I try to build on my production server, the build fails when trying to run my tests, and throws this error here ( I just did a copy pest of the error)

[INFO] --- frontend-maven-plugin:1.0:grunt (grunt-karma) @ forecast-guardian-4 ---
[INFO] Running 'grunt ' in /var/lib/jenkins/workspace/TaskName
[INFO] Running "karma:unit" (karma) task
ERROR [launcher]: [39mNo binary for Chrome browser on your platform.
[INFO]   Please, set "CHROME_BIN" env variable.
[INFO] 
[INFO] 
[INFO] 
[INFO] [33mWarning: Task "karma:unit" failed. Use --force to continue.[39m
[INFO] 
[INFO] [31mAborted due to warnings.[39m
[INFO] 

My research on that shows how to set that variable if you are on the local machine, which I didn't have to do by the way. I was wondering if anyone can help me configure this.

How can I set this variable to produce something like what find here for setting it on local machine?

More info: As that error shows, my project uses grunt to run the test.

Thank you.


Solution

  • You could either use the EnvInject plugin or put export CHROME_BIN=/your/path/here into .bash_profile and run source ~/.bash_profile at the beginning of your job.