From 4b98b457c164c3314685eca7999c8c9b55ca1e2b Mon Sep 17 00:00:00 2001 From: mikeTWC1984 Date: Sun, 21 Apr 2024 23:12:26 -0400 Subject: [PATCH] sshx - add annotate opt --- bin/sshx-plugin.js | 5 ++++- sample_conf/setup.json | 7 ++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/bin/sshx-plugin.js b/bin/sshx-plugin.js index d991f0d..980fd6d 100644 --- a/bin/sshx-plugin.js +++ b/bin/sshx-plugin.js @@ -9,7 +9,10 @@ const fs = require('fs') // read job info from stdin (sent by Cronicle engine) const job = JSON.parse(fs.readFileSync(process.stdin.fd)) -const print = (text) => process.stdout.write(text + EOL) +let pref = '' +if(job.params.annotate) pref = `[${new Date().toISOString()}] ` + +const print = (text) => process.stdout.write(pref + text + EOL) const printInfo = (text) => process.stdout.write(`[INFO] \x1b[32m${text}\x1b[0m` + EOL) const printWarning = (text) => process.stdout.write(`[INFO] \x1b[33m${text}\x1b[0m` + EOL) const printError = (text) => process.stdout.write(`\x1b[31m${text}\x1b[0m` + EOL) diff --git a/sample_conf/setup.json b/sample_conf/setup.json index f853da1..e90d530 100644 --- a/sample_conf/setup.json +++ b/sample_conf/setup.json @@ -87,9 +87,10 @@ { "id":"ssh_host", "type":"text", "size":40, "title":"SSH Host", "value": "ssh://cronicle:Password@localhost:22" }, { "id":"kill_cmd", "type":"text", "size":40, "title":"Kill Command", "value": "pkill -s $$" }, { "id":"script", "type":"textarea", "rows":10, "title":"Script", "value": "\n#!/bin/sh\n\necho \"Running SSHX job on $HOSTNAME\"\n\nsleep 10\n\n# Specify conneciton info using URI format:\n# [ssh://]user[:Password]@host[:port]?[privateKey=/path/to/file&passphrase=Password]\n# URI can be passed directly or as a reference to environment variable\n# If passing password via URI, you'd need to encode special characters (e.g. @ => %40)\n# You can also set SSH_KEY/SSH_PASSWORD/SSH_PASSPHRASE as variables in event/plugin secrets\n\n# If no SSH Host specified on event parameters, it can be resolved from WF argument\n\n# Kill Command parameter is used to properly handle job abortion\n# Default command is [pkill -S $$]\n# $$ is refering to PID of your script parent process (bootstrap script)\n\n# To pass variables other then JOB_ / ARG*, use SSH_ prefix on variable name\n# If this event is chained by other job, you can access chain data using CHAIN_DATA variable\n\n" }, - {"type":"select","id":"lang","title":"syntax","items":["shell","powershell","javascript","python","perl","groovy","java","csharp","scala","sql","yaml","dockerfile","json","props"],"value":"shell"}, - {"type":"select","id":"theme","title":"theme","items":["default","gruvbox-dark","solarized light","solarized dark","darcula","ambiance","base16-dark","nord"],"value":"default"}, - { "id":"json", "type":"checkbox", "title":"Interpret JSON in Output", "value": 0 } + { "id":"json", "type":"checkbox", "title":"Interpret JSON in Output", "value": 0 }, + { "type": "checkbox", "id": "annotate", "title": "Add Date/Time Stamps to Log", "value": 0 }, + { "type":"select","id":"lang","title":"syntax","items":["shell","powershell","javascript","python","perl","groovy","java","csharp","scala","sql","yaml","dockerfile","json","props"],"value":"shell"}, + { "type":"select","id":"theme","title":"theme","items":["default","gruvbox-dark","solarized light","solarized dark","darcula","ambiance","base16-dark","nord"],"value":"default"} ] } ],