Class: Fuel::CLI::Jenkins

Inherits:
Base
  • Object
show all
Includes:
GerritCommon
Defined in:
lib/fuel/cli/jenkins.rb

Instance Method Summary collapse

Methods included from GerritCommon

#changes_endpoint, #fetch_change_id_or_fail, #gerrit_ref, #gerrit_url

Instance Method Details

#artifactsObject



50
51
52
53
54
55
56
57
# 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) ⇒ Object



60
61
62
# File 'lib/fuel/cli/jenkins.rb', line 60

def auth(user)
  set_credentials(user, ['jenkins', :username], ['jenkins', :password])
end

#deployObject



20
21
22
23
24
25
26
27
28
# 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

#openObject



13
14
15
16
17
# File 'lib/fuel/cli/jenkins.rb', line 13

def open
  build_link = build_link_or_fail

  `open #{build_link}`
end

#statusObject



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# 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