39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
|
# File 'lib/ciflows/cli.rb', line 39
def process
flow = Ciflows::Project.new(options[:repo], options[:branch], options[:build], options[:job])
begin
flow.process
build_icon = flow.build['status'] == 'success' ? "✅": "❌"
say("Workflow INFO: #{build_icon}", :blue)
print_table(flow.build)
case flow.build['status']
when 'failed', 'failing'
say("\n")
say("Workflow #{flow.build['id']} failed/failing", :red)
say('Failed Jobs', :blue)
print_table(flow.failed_jobs.map(&:to_h).map(&:values))
say("\n Actions: " \
"\n 1. Rerun from failed" \
"\n 2. Rerun from begining" \
"\n 3. Go to workflow (only support Google Chrome)")
answer = ask('What do you want to go next?', :yellow, limited_to: %w[1 2 3])
case answer.to_i
when 1
flow.rerun_workflow_from('failed')
when 2
flow.rerun_workflow_from('beginning')
when 3
Launchy.open("https://circleci.com/workflow-run/#{flow.build['id']}")
else
say_status('failed', "failed #{self}")
end
when 'on_hold', 'running'
say("Workflow #{flow.build['id']} is on_hold/running", :yellow)
if options[:run] == 'true' || yes?('Do you want to approve it? (y/n)', :yellow)
flow.approve_workflow
end
when 'success'
say('success', "Workflow #{flow.build['id']} succeeded", :green)
end
rescue Graphlient::Errors::ExecutionError => e
say_status('fail', e.message, :red)
end
end
|