diff options
Diffstat (limited to 'app/jobs/govuk_guix/job.rb')
-rw-r--r-- | app/jobs/govuk_guix/job.rb | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb index 342eb9d..a48ce02 100644 --- a/app/jobs/govuk_guix/job.rb +++ b/app/jobs/govuk_guix/job.rb @@ -19,9 +19,22 @@ # <http://www.gnu.org/licenses/>. require 'open3' +require 'shellwords' class GovukGuix::Job < Que::Job - def run_command(*command) + def run_command(*command, run_remotely_on_host: nil) + if run_remotely_on_host + command = command.map do |arg| + Shellwords.escape(arg) + end + + command = [ + 'ssh', + run_remotely_on_host, + *command + ] + end + logger.debug("#{self.class}: Running command #{command.join(' ')}") Open3.popen2e(*command) do |_stdin, stdout_and_stderr, wait_thr| |