capistrano + jenkins

Yet another ruby gem: jenkins_cap

This one allows you to tie your Capistrano deployment to your Jenkins build, such that a deployment only occurs if the revision (SVN) has been successfully built on Jenkins. The gem pulls data from Jenkin’s JSON API via wget. (TODO: Use Ruby to make the API request).

To add it to you deployment just specific your Jenkins host url, and the name of you Jenkin’s build. Then add the “jenkins_cap:build_check” to one of your Capistrano hook.

Example usage:

set :jenkins_host, "http://jenkins.example.com"
set :jenkins_job_name, "mybuild"

before 'deploy', 'jenkins_cap:build_check' # check if the revision has been built by Jenkins successfully
Advertisements
Tagged with: , , , , ,
Posted in capistrano, hudson, jenkins, ruby, rubygem

cap_permission

Another Capistrano ruby gem: cap_permission.
This ruby gem allows you to control who can run Capistrano. You can set permissions based on a user’s group membership, or create a list of “deployment_users” who are allowed to run Capistrano.

By default users in “root”, “sysadmins”, and “confmgmt” groups are granted permission.

require 'cap_permission'

set :group_name, "releasemgmt" # allows users in 'releasemgmt' group to run cap tasks

set :deployment_users, ["leeroy", "jenkins"] # allows user 'leeroy' and user 'jenkins' to run cap tasks
Tagged with: , , , ,
Posted in capistrano, ruby, rubygem

caplock: a capistrano ruby gem

After a long arduous battle (gross exaggeration) fighting for Capistrano we are finally implementing it at my company. Of course we have found that Capistrano doesn’t always work the way we would like it to. Luckily Capistrano seems pretty easily extendable.
Today I created caplock, a ruby gem to prevent Capistrano from preforming simultaneous deployments. This is the basic workflow:

Before a deployment:
1. abort if the lock file exists on the remote server (this means another deployment is already in progress)
2. create a lock file on remote server

After a deployment:
1. remove the lock file

Tagged with: , , ,
Posted in capistrano, ruby

Command Line Interface for Pingdom API

At Gorilla Nation we use Pingdom to monitor our websites. We have a lot of websites so in order to automatically add/remove our websites from Pingdom I created a command line interface to Pingdom’s API. My command line interface is based on drcraig’s python module for Pingdom.

pingdom-cli allows you to easily create, read, update and delete Pingdom checks:

usage: ./pingdom-cli COMMAND CHECK_NAME [PARAMS]

    Commands:
        add       - add a check
        delete    - delete a check by name
        info      - get JSON dump of check info
        modify    - modify a check
        listnames - list all check names
        listids   - list all check ids
        listsites - list all HTTP checks
        credits   - return info on remaining checks and credits

Adding a check:

./pingdom-cli add druwerd.com
Adding druwerd.com
{u'check': {u'id': 443593, u'name': u'druwerd.com'}}

Modifying a check:

./pingdom-cli modify druwerd.com  '{"host" : "github.com/Druwerd" }'
{u'message': u'Modification of check was successful!'}

Deleting a check:

./pingdom-cli delete druwerd.com
Deleting check 443593
{u'message': u'Deletion of check was successful!'}
Tagged with: , ,
Posted in python

Hudson (Jenkins) Ruby Gem 0.3.1

Looks like my humble little ruby gem has gathered some interest on GitHub https://github.com/Druwerd/hudson-remote-api/network =)
It’s great to see other people working with the code base and expanding upon it.

I just finished merging the latest pull requests and released a new version hudson-remote-api 0.3.1

New Features & Fixes:

  • fixed https support – Jai Singh
  • Add in #url method to Job – Jon Moses
  • Regexp patch XML from git based projects – Jon Moses
  • Pull at the culprit of failing builds – Jon Moses
  • Added crumb fetching – Jason Rickman

Thanks to everyone who contributed!

Tagged with: , , ,
Posted in hudson, jenkins, ruby

Party Scroller

I came across this article on MAKE: Party Scroller

Very cool idea, but since I don’t have an actual LED scroller I decided to make a web version: https://github.com/Druwerd/party-scroller

The functionality is basically the same. You send your text message to a Google voice number and your message is displayed on a web page.

However, I used different technology for my implementation:

Tagged with: , , , , ,
Posted in javascript, ruby, sinatra

Colorful Terminal Output

Add some color to your ruby scripts.
Simply extend the ruby string class using the term-ansicolor gem.

#!/usr/bin/ruby

require "rubygems"
require "term/ansicolor"

class String
  include Term::ANSIColor
end

puts "Hello World".red
Tagged with: , , , ,
Posted in ruby