Project

General

Profile

Download (743 Bytes) Statistics
| Branch: | Tag: | Revision:

foreman_pipeline / app / lib / actions / foreman_pipeline / job / cv_promote_job_hook.rb @ be52ca64

1
module Actions
2
  module ForemanPipeline
3
    module Job
4
      class CvPromoteJobHook < JobHook
5

    
6
        def self.subscribe
7
          Katello::ContentView::Promote
8
        end
9

    
10
        def plan(version, environment, is_force = false)          
11
          valid_jobs = version.content_view.jobs.select { |job| job.is_valid? }
12
          jobs_to_run = valid_jobs.select { |job| version.eql? job.target_cv_version }
13
          allowed_jobs = jobs_to_run.select { |job| job.levelup_trigger && !job.version_already_promoted? }
14
          
15
          plan_self(:trigger => trigger.output,
16
                    :job_ids => allowed_jobs.map(&:id),
17
                    :job_names => allowed_jobs.map(&:name))    
18
        end        
19
      end
20
    end
21
  end
22
end