'Rundeck job notification error (server response: 415 Unsupported Media Type)
rundeck ver: 4.0.0
I want to send job execution result to specific webhook url. So I set job notification use GUI
Trigger: On success
Notification Type: Send Webhook
URL(s): specific incoming webhook url
Payload Format: JSON
Method: POST
Rundeck job notification error is occured. (server response: 415 Unsupported Media Type)
Is there a configuration file that needs to be added other than the job notifications settings?
Solution 1:[1]
To send the job execution result you can use the HTTP notification plugin and put an export variable (containing the result) in the body section.
For this, you need to "capture" the output and store it on a global variable to put in the notification, I made a workable example that works with webhooks.site test service:
- defaultTab: nodes
description: ''
executionEnabled: true
id: bcee72e0-b6fa-4e8e-a065-9937a67f3de7
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
notification:
onsuccess:
plugin:
configuration:
authentication: None
body: ${export.myexport}
contentType: application/json
method: POST
remoteUrl: https://webhook.site/xxxx-xxxx-xxxx-xxxx-xxxx
timeout: '30000'
type: HttpNotification
notifyAvgDurationThreshold: null
options:
- name: opt1
value: localhost
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- exec: nmap ${option.opt1}
plugins:
LogFilter:
- config:
hideOutput: 'false'
logData: 'true'
name: myoutput
regex: (.*)
type: key-value-data-multilines
- description: only for debug
exec: echo ${data.myoutput}
- configuration:
export: myexport
group: export
value: ${data.myoutput*}
nodeStep: false
type: export-var
keepgoing: false
strategy: node-first
uuid: bcee72e0-b6fa-4e8e-a065-9937a67f3de7
Run command and capture the output in a data capture filter, I use the Multiline Regex Data Capture plugin, now the output is saved on a data variable called
${data.myoutput}.Then using the Global Variable Workflow Step, take the
${data.myoutput}(using the${data.myoutput*}format) and create the${export.myexport}variable to use in notifications (just putting the${export.myexport}variable).Check the result.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | MegaDrive68k |
