Skip to content

Instantly share code, notes, and snippets.

@toolmantim
Last active May 25, 2021 11:49
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save toolmantim/ff58646e05f0866e422d638f7ae34d8c to your computer and use it in GitHub Desktop.
Save toolmantim/ff58646e05f0866e422d638f7ae34d8c to your computer and use it in GitHub Desktop.
Using rvm and node on Ubuntu with Buildkite Agent

Firstly, you'll need to install rvm as the buildkite-agent user:

sudo su buildkite-agent
curl -sSL https://get.rvm.io | bash -s stable
source /var/lib/buildkite-agent/.rvm/scripts/rvm
rvm install 2.4.0 && rvm use 2.4.0 && gem install bundler

Secondly, make rvm available to your build commands by adding the following pre-command Buildkite Agent hook:

#!/bin/bash

# Place this in /etc/buildkite-agent/hooks/pre-command
#
# Needs to be `chown buildkite-agent` and `chmod +x`

# RVM uses unbound variables and will fail without this
set +u

source /var/lib/buildkite-agent/.rvm/scripts/rvm

Finally, set up your build pipeline with the following two steps and run a build:

:ruby:

bundle install && bundle exec ruby test.rb

:node:

npm install && node test.js

build-screenshot

source "https://rubygems.org"
gem "rack"
ruby "2.4.0"
{
"dependencies": {
"left-pad": "x"
}
}
const leftPad = require('left-pad')
console.log(leftPad("I've loaded a node JS lib", 80))
require "rack"
puts Rack::Utils.escape("I've loaded a gem")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment