|
20 | 20 | # limitations under the License.
|
21 | 21 | #
|
22 | 22 |
|
23 |
| -#pruned Chef::Provider::Execute + optional `block' param |
24 |
| - |
25 |
| -include Chef::Mixin::Command |
| 23 | +require 'chef/mixin/shell_out' |
| 24 | +include Chef::Mixin::ShellOut |
26 | 25 |
|
27 | 26 | def action_run
|
28 |
| - args = { |
29 |
| - :command => @new_resource.command, |
30 |
| - :command_string => @new_resource.to_s, |
31 |
| - } |
32 |
| - args[:only_if] = @new_resource.only_if if @new_resource.only_if |
33 |
| - args[:not_if] = @new_resource.not_if if @new_resource.not_if |
34 |
| - args[:timeout] = @new_resource.timeout if @new_resource.timeout |
35 |
| - args[:cwd] = @new_resource.cwd if @new_resource.cwd |
36 |
| - |
37 |
| - status, stdout, stderr = output_of_command(args[:command], args) |
38 |
| - if status.exitstatus == 0 |
39 |
| - @new_resource.block.call(stdout) if @new_resource.block |
40 |
| - @new_resource.updated_by_last_action(true) |
41 |
| - Chef::Log.info("Ran #{@new_resource} successfully") |
42 |
| - else |
43 |
| - command_output = "JENKINS STDOUT: #{stdout}" |
44 |
| - command_output << "JENKINS STDERR: #{stderr}" |
45 |
| - handle_command_failures(status, command_output, args) |
46 |
| - end |
| 27 | + args = {} |
| 28 | + args[:timeout] = new_resource.timeout if new_resource.timeout |
| 29 | + args[:cwd] = new_resource.cwd if new_resource.cwd |
| 30 | + cmd = shell_out!(new_resource.command, args) |
| 31 | + new_resource.block.call(cmd.stdout) if new_resource.block |
| 32 | + new_resource.updated_by_last_action(true) |
| 33 | + Chef::Log.info("Ran #{new_resource} successfully") |
47 | 34 | end
|
0 commit comments