Using JRuby

A small wrapper program named ec-jruby is installed as part of the CloudBees Flow tools. You can use it to run JRuby scripts.

Default Location of ec-jruby

  • The default location for ec-jruby on Linux is

    /opt/electriccloud/electriccommander/bin/ec-jruby
  • The default location for ec-jruby on Windows is

    C:\Program Files\Electric Cloud\ElectricCommander\bin\ec-jruby

CloudBees Flow automatically adds ec-jruby to your path.

Running ec-jruby

To run ec-jruby :

  1. Set COMMANDER_HOME and COMMANDER_DATA as environment variables.

  2. Enter ec-jruby <yourJRubyOptions> <JRubyScriptName>.rb on the command line.

There is no language-specific binding for JRuby. Use the REST API to communicate with the CloudBees Flow server.

Example of a JRuby Script

require 'net/https'
require 'cgi'

uri = URI.parse("https://" + ENV["COMMANDER_SERVER"] + ":" +
ENV["COMMANDER_HTTPS_PORT"] + "/rest/v1.0/projects")

http = Net::HTTP.new(uri.host, uri.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Get.new(uri.request_uri)

cookie = CGI::Cookie.new('sessionId',ENV["COMMANDER_SESSIONID"])
request['Cookie'] = cookie.to_s

response = http.request(request)

puts response.body