web47core 3.2.3.49 → 3.2.3.50
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 +20 -7
- 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: 6919700b0f69654fb86470e9ff727198e1e5e8da157240eb58f869597c95b497
|
|
4
|
+
data.tar.gz: eaa6281463cd954391791d53eeaee3b21875764bed20f554886de54d3209d7cd
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 7657edbc6f8674bee74604a85aa58bc1e61e5562052ad096b20beaeff701345820e801f6af00f589a9b9b6dddd669e6257767e1fca7d05b9b4cd8bbdf161cda1
|
|
7
|
+
data.tar.gz: c85f3e3a93c533fa1f5863cf48204dc933e6a81ebf1c7a907d4a60a9a4ccea73f3562b27cf7eb9fcdade153abffa3c34f0cb61df84f7a7bbb7b2492a73f49479
|
|
@@ -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
|
#
|
|
@@ -329,11 +331,9 @@ class CommandJob
|
|
|
329
331
|
#
|
|
330
332
|
def run_command(command, dir = '/tmp', options = {})
|
|
331
333
|
command = command.join(' ') if command.is_a?(Array)
|
|
332
|
-
output =
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
end
|
|
336
|
-
output = 'Success' if output.blank?
|
|
334
|
+
output, status = Open3.capture2e(command, chdir: dir)
|
|
335
|
+
output = mask_keywords(output, options[:mask_texts])
|
|
336
|
+
output = status.success? ? 'Success' : 'No output' if output.blank?
|
|
337
337
|
command = mask_keywords(command, options[:mask_texts])
|
|
338
338
|
if block_given?
|
|
339
339
|
yield output
|
|
@@ -341,6 +341,7 @@ class CommandJob
|
|
|
341
341
|
logs.create!(dir: dir, command: command, message: output)
|
|
342
342
|
end
|
|
343
343
|
options[:output_limit] ||= -1
|
|
344
|
+
check_for_success(command, status, output, output_limit: options[:output_limit])
|
|
344
345
|
check_for_text(output, options[:error_texts], output_limit: options[:output_limit])
|
|
345
346
|
check_for_text(output, options[:required_texts], inclusive_check: false, output_limit: options[:output_limit])
|
|
346
347
|
output
|
|
@@ -359,10 +360,22 @@ class CommandJob
|
|
|
359
360
|
output
|
|
360
361
|
end
|
|
361
362
|
|
|
362
|
-
#
|
|
363
|
+
# @abstract Check if we were success
|
|
364
|
+
# @param command [String] The command that was run
|
|
365
|
+
# @param status [Process::Status] Status returned from the command
|
|
366
|
+
# @param output [String] The output returned from the command
|
|
367
|
+
# @param output_limit [Integer] Limit of output to show in error message
|
|
368
|
+
# @return [Boolean] true if we were success
|
|
369
|
+
def check_for_success(command, status, output, output_limit: -1)
|
|
370
|
+
return if status.success?
|
|
371
|
+
|
|
372
|
+
reason = status.signaled? ? "signal #{status.termsig}" : "exit status #{status.exitstatus}"
|
|
373
|
+
error_output = output.slice(0, output_limit) || output
|
|
374
|
+
raise "Command failed with #{reason}: #{command} - #{error_output}"
|
|
375
|
+
end
|
|
376
|
+
|
|
363
377
|
# Check if any occurrences were found (or not found)
|
|
364
378
|
# For most command jobs, we want to see the full output. -1 accomplishes this
|
|
365
|
-
#
|
|
366
379
|
def check_for_text(output, texts = [], inclusive_check: true, output_limit: -1)
|
|
367
380
|
return if texts.blank?
|
|
368
381
|
|
data/lib/web47core/version.rb
CHANGED