class Fuel::CLI::Jenkins
Public Instance Methods
artifacts()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 50 def artifacts build_link = build_link_or_fail details = build_details say 'No artifacts available, build might be still running', :yellow and return if details['artifacts'].empty? `open #{build_link}artifact/` end
auth(user)
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 60 def auth(user) set_credentials(user, ['jenkins', :username], ['jenkins', :password]) end
deploy()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 20 def deploy change_id = fetch_change_id_or_fail result = self.class.get(changes_endpoint(change_id, "?o=CURRENT_REVISION")).parsed_response current_rev = result['current_revision'] client = create_client ref = gerrit_ref(result).sub('refs/', '') client.job.build("ui.fuel-deploy.gerrit", { "Environment" => "qa", "GerritRef" => ref }) end
open()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 13 def open build_link = build_link_or_fail `open #{build_link}` end
status()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 31 def status details = build_details result = details['result'] say 'Build is still running', :yellow and return unless result color = case result when "FAILURE", "ABORTED" :red when "SUCCESS" :green else :default end say result, color say 'Build artifacts are available via "jenkins artifacts"' end
Private Instance Methods
build_details()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 66 def build_details build_link = build_link_or_fail build_number = build_link =~ /\/(\d+)\// && $1 client = create_client client.job.get_build_details("ui.fuel-gerrit", build_number) end
build_link_or_fail()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 78 def build_link_or_fail change_id = fetch_change_id_or_fail result = self.class.get(changes_endpoint(change_id, "detail")).parsed_response build_message = result['messages'].reverse.find { |m| m['author']['username'] == 'hbuilduser' } build_message &&= build_message['message'] build_link = build_message && URI.extract(build_message)[0] raise Thor::Error, set_color('No Jenkins build found for this change', :red) unless build_link build_link end
create_client()
click to toggle source
# File lib/fuel/cli/jenkins.rb, line 74 def create_client @client ||= Fuel::Util::JenkinsClient.new(Config.get('jenkins')) end