Skip to content

Instantly share code, notes, and snippets.

@nonrational
Created July 14, 2015 15:09
Show Gist options
  • Save nonrational/6fca09784660491e74ad to your computer and use it in GitHub Desktop.
Save nonrational/6fca09784660491e74ad to your computer and use it in GitHub Desktop.
simple jenkins build wrapper class to fetch parameters
class Build
def initialize(build_json)
@json = build_json
end
def params
if action_node_with_params = @json['actions'].find { |a| a['parameters'] }
action_node_with_params['parameters']
end
end
def param_value(param_name)
if named_param_node = self.params.find { |p| p['name'] == param_name }
named_param_node['value']
end
end
def number
@json['number']
end
def building?
@json['building']
end
end
b = Build.new JSON.parse(File.read("./builds.json"))
puts b.param_value('ghprbPullId')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment