web47core 3.2.3.49 → 3.2.3.51
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/app/models/command_job.rb +26 -11
- data/lib/web47core/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 683f85833d91a9351863dac2996336e09fe452e7084372872c124b77e3e29781
|
|
4
|
+
data.tar.gz: 65e1da14f9427778e084a916d2466f26b3d116f9e5c7b602cdbe744d35e12a91
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: eb912939e26c729a3f869f101e0b79b7a22a69cb476ba4bed2b7d8dac1fb5506f7439937845a25d7b63b6f5560635d1230bfc88c54c7db3a1f95f0796c572706
|
|
7
|
+
data.tar.gz: 1595561313f0b17963e0a7acdbf3f15834faae4e1a990b87d1520eb8afc4bf7dece91c6f03e051d6d9f5d413fd996a0ed05b005aedc49338b4b46475d10ace28
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
|
+
require 'open3'
|
|
4
|
+
|
|
3
5
|
#
|
|
4
6
|
# Base class for all jobs that will be run on builds
|
|
5
7
|
#
|
|
@@ -324,16 +326,16 @@ class CommandJob
|
|
|
324
326
|
run_command "unzip #{file_path}", to_dir, error_texts: 'unzip:'
|
|
325
327
|
end
|
|
326
328
|
|
|
327
|
-
#
|
|
328
|
-
#
|
|
329
|
-
#
|
|
329
|
+
# @abstract Run the command capturing the command output and any standard error to the log.
|
|
330
|
+
# @param command [String|Array] The command that needs to be run
|
|
331
|
+
# @param dir [String] The directory where the command needs to be run
|
|
332
|
+
# @param options [Hash] Options for the command
|
|
333
|
+
# @return [String] The output of the command
|
|
330
334
|
def run_command(command, dir = '/tmp', options = {})
|
|
331
|
-
command =
|
|
332
|
-
output =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
end
|
|
336
|
-
output = 'Success' if output.blank?
|
|
335
|
+
command = Shellwords.shelljoin(command) if command.is_a?(Array)
|
|
336
|
+
output, status = Open3.capture2e(command, chdir: dir)
|
|
337
|
+
output = mask_keywords(output, options[:mask_texts])
|
|
338
|
+
output = status.success? ? 'Success' : 'No output' if output.blank?
|
|
337
339
|
command = mask_keywords(command, options[:mask_texts])
|
|
338
340
|
if block_given?
|
|
339
341
|
yield output
|
|
@@ -341,6 +343,7 @@ class CommandJob
|
|
|
341
343
|
logs.create!(dir: dir, command: command, message: output)
|
|
342
344
|
end
|
|
343
345
|
options[:output_limit] ||= -1
|
|
346
|
+
check_for_success(command, status, output, output_limit: options[:output_limit])
|
|
344
347
|
check_for_text(output, options[:error_texts], output_limit: options[:output_limit])
|
|
345
348
|
check_for_text(output, options[:required_texts], inclusive_check: false, output_limit: options[:output_limit])
|
|
346
349
|
output
|
|
@@ -359,10 +362,22 @@ class CommandJob
|
|
|
359
362
|
output
|
|
360
363
|
end
|
|
361
364
|
|
|
362
|
-
#
|
|
365
|
+
# @abstract Check if we were success
|
|
366
|
+
# @param command [String] The command that was run
|
|
367
|
+
# @param status [Process::Status] Status returned from the command
|
|
368
|
+
# @param output [String] The output returned from the command
|
|
369
|
+
# @param output_limit [Integer] Limit of output to show in error message
|
|
370
|
+
# @return [Boolean] true if we were success
|
|
371
|
+
def check_for_success(command, status, output, output_limit: -1)
|
|
372
|
+
return if status.success?
|
|
373
|
+
|
|
374
|
+
reason = status.signaled? ? "signal #{status.termsig}" : "exit status #{status.exitstatus}"
|
|
375
|
+
error_output = output.slice(0, output_limit) || output
|
|
376
|
+
raise "Command failed with #{reason}: #{command} - #{error_output}"
|
|
377
|
+
end
|
|
378
|
+
|
|
363
379
|
# Check if any occurrences were found (or not found)
|
|
364
380
|
# For most command jobs, we want to see the full output. -1 accomplishes this
|
|
365
|
-
#
|
|
366
381
|
def check_for_text(output, texts = [], inclusive_check: true, output_limit: -1)
|
|
367
382
|
return if texts.blank?
|
|
368
383
|
|
data/lib/web47core/version.rb
CHANGED