Skip to content

Instantly share code, notes, and snippets.

@jessereynolds
Last active August 1, 2016 02:30
Show Gist options
  • Save jessereynolds/a43ba17727695b5b472d591683d9ba62 to your computer and use it in GitHub Desktop.
Save jessereynolds/a43ba17727695b5b472d591683d9ba62 to your computer and use it in GitHub Desktop.
Installing rbenv, ruby, bundler on Bamboo for Puppet testing

Installing rbenv, ruby, bundler on Bamboo

The following details how to install rbenv, ruby, bundler on a RHEL / CentOS Bamboo build agent.

On the bamboo agent/server machine, bamboo.example, install rbenv as per its docs:

yum install -y openssl-devel readline-devel zlib-devel
su - bamboo
git clone https://github.com/rbenv/rbenv.git ~/.rbenv
cd ~/.rbenv && src/configure && make -C src
echo 'export PATH="$HOME/.rbenv/bin:$PATH"' >> ~/.bash_profile
echo 'eval "$(rbenv init -)"' >> ~/.bash_profile
exit

su - bamboo
type rbenv # this should return with "rbenv is a function"

Now, install the ruby-build plugin for rbenv as per its docs:

git clone https://github.com/rbenv/ruby-build.git ~/.rbenv/plugins/ruby-build

Now, install version 2.1.9 of ruby (or the desired version) as per the rbenv ruby install instructions (the version of Ruby bundled with PE 2016.2.0 - see https://docs.puppet.com/pe/2016.2/overview_version_table.html ) ie:

rbenv install -l       # lists out all versions of ruby known to ruby-build
rbenv install 2.1.9    # this downloads the ruby 2.1.9 source, compiles and installs it under ~bamboo/.rbenv/versions/
rbenv rehash           # this sets up shims for all executables in ruby and ruby gems known to rbenv
rbenv global 2.1.9     # this sets ruby 2.1.9 as the default ruby to run
ruby --version         # you should see "ruby 2.1.9p490 (2016-03-30 revision 54437) [x86_64-linux]"

Install the bundler ruby gem:

gem install bundler

Add executable "bundle" to Bamboo

We'll add the executable ~/.rbenv/shims/bundle to Bamboo. This lets rbenv decide which version of ruby to run its bundler.

Add two tasks to the control-repo plan:

  • command: bundler, arguments: install (will run bundle install)
  • command: bundler, arguments: exec onceover run spec (will run bundle exec onceover run spec)

Add ssh key for bamboo user to puppetserver user in bitbucket:

su - bamboo
ssh-keygen -t dsa
-> Generating public/private dsa key pair.
-> Enter file in which to save the key (/opt/atlassian/bamboo/home/.ssh/id_dsa):


Accept the stash host key:
su - bamboo
git clone --mirror ssh://[email protected]:7999/pup/control-repo.git /tmp/control-repo.git # enter ‘yes’ and return

Add more tasks to the plan using the Bundler executable:

  • command: bundler, argument: exec rake syntax (will run: bundle exec rake syntax)
  • command: bundler, argument: exec rake validate_ruby
  • command: bundler, argument: exec rake profile_spec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment