Skip to content

Commit

Permalink
sshx - add annotate opt
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeTWC1984 committed Apr 22, 2024
1 parent 57e4a3e commit 4b98b45
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
5 changes: 4 additions & 1 deletion bin/sshx-plugin.js
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
7 changes: 4 additions & 3 deletions sample_conf/setup.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"}
]
} ],

Expand Down

0 comments on commit 4b98b45

Please sign in to comment.