1
|
module Actions
|
2
|
module ForemanPipeline
|
3
|
module Job
|
4
|
class Promote < Actions::EntryAction
|
5
|
middleware.use ::Actions::Middleware::KeepCurrentUser
|
6
|
|
7
|
def plan(opts)
|
8
|
plan_self(opts)
|
9
|
end
|
10
|
|
11
|
def run
|
12
|
unless job.environment.successors.empty?
|
13
|
fail "Content View promotion disabled" if job.to_environments.empty?
|
14
|
promote_environment
|
15
|
end
|
16
|
end
|
17
|
|
18
|
def rescue_strategy_for_self
|
19
|
Dynflow::Action::Rescue::Skip
|
20
|
end
|
21
|
|
22
|
private
|
23
|
|
24
|
def promote_environment
|
25
|
output[:cv_to_promote] = job.content_view.name
|
26
|
output[:target_environments] = job.to_environments.pluck(:name)
|
27
|
output[:in_job] = job.name
|
28
|
|
29
|
ForemanTasks.trigger(Job::MultiplePromotions, job)
|
30
|
end
|
31
|
|
32
|
def job
|
33
|
j = ::ForemanPipeline::Job.find input.fetch(:job_id)
|
34
|
end
|
35
|
end
|
36
|
end
|
37
|
end
|
38
|
end
|