Project

General

Profile

Download (1.08 KB) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / app / lib / actions / foreman_pipeline / job / promote.rb @ 9fb80abe

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? #when we are not at the end of lifecycle path
13
            fail "Content View promotion disabled" unless job.should_be_promoted?
14
            fail "Content view already promoted to the next environment(s), skipping promotion(s)" unless job.promotion_safe?
15
            promote_environment
16
          end
17
        end
18

    
19
        def rescue_strategy_for_self
20
          Dynflow::Action::Rescue::Skip
21
        end
22

    
23
        private
24

    
25
        def promote_environment
26
          output[:cv_to_promote] = job.content_view.name
27
          output[:target_environments] = job.to_environments.pluck(:name)
28
          output[:in_job] = job.name
29

    
30
          ForemanTasks.trigger(Job::MultiplePromotions, job)
31
        end
32

    
33
        def job
34
          j = ::ForemanPipeline::Job.find input.fetch(:job_id)
35
        end
36
      end
37
    end
38
  end
39
end