Anthony O.
Anthony O.

Reputation: 24377

How to install a ruby gem in Jenkins?

I'm looking for a way to install ruby, gem and finally a specific gem (sass & compass actually) only with the jenkins account (which is not root).

I had a look at rvm but it tries to do a sudo to install ruby in "Single-User" mode (trying to apt-get it), so it fails because we are not in interactive bash, and my jenkins user would not have rights to install stuffs in Ubuntu anyways.

Any idea?

Upvotes: 1

Views: 6613

Answers (2)

minusf
minusf

Reputation: 1373

Does the machine have compiler tools installed (gcc, etc)? At certain point in the reqirements list it will be necessary to install some binary packages using root... It would save a lot of hassle if you could install a binary package ruby.

However if the compiler toolchain is available, one can always compile ruby as non-root by specifying configure parameters. Note, that you will have to download the source code and compile all the other libraries it depends on as well.

Installing gems for a given user is trivial, just run gem install as non-root and it will install the runnable commands under $HOME/bin. (The actual gems will be under $HOME/.gem)

Upvotes: 0

mcfinnigan
mcfinnigan

Reputation: 11638

  1. sudo su -l
  2. rvm use $your_ruby
  3. gem install sass
  4. chown -R jenkins:jenkins $sass_install_directory

this is probably the simplest way.

If you're trying to do this multiple times, it's better to change the rvm gems folder's permissions so that the jenkins user owns it - root would still be able to install there.

Upvotes: 1

Related Questions