Project

General

Profile

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

foreman_pipeline / app / lib / actions / foreman_pipeline / jenkins / wait_for_build.rb @ be52ca64

1
module Actions
2
  module ForemanPipeline
3
    module Jenkins
4
      class WaitForBuild < WaitAndPoll        
5
        
6
        def poll_interval
7
          10
8
        end
9

    
10
        def rescue_strategy_for_self
11
          Dynflow::Action::Rescue::Skip
12
        end
13

    
14
        def run(event = nil)
15
          unless event == Dynflow::Action::Skip
16
            super
17
          end
18
        end
19

    
20
        def external_task=(external_task_data)
21
          if external_task_data.is_a?(Hash)
22
            output[:result] = !external_task_data[:result].nil?
23
            if external_task_data[:result] == "FAILURE"
24
              fail "Jenkins build failed"          
25
            end
26
          end                    
27
        end
28

    
29
        private
30

    
31
        def poll_external_task
32
          details = job.jenkins_instance.client.job
33
                      .get_build_details(input.fetch(:name), input.fetch(:build_num))
34
                      .with_indifferent_access
35
          output[:details] = details
36
          details
37
        end
38

    
39
      end
40
    end
41
  end
42
end