Created
July 14, 2015 15:09
-
-
Save nonrational/6fca09784660491e74ad to your computer and use it in GitHub Desktop.
simple jenkins build wrapper class to fetch parameters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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