How to attach rundeck execution log for sending via curl? - webhooks

I'm developing a script on rundeck, sending custom webhooks.
But I am not able to send the log of the work execution itself.
I need the execution log to be sent in the message body.
As in the example:
Log rundeck:
enter image description here
I need this log to be in the body of the message, I've tried some ways but it didn't work, does anyone have any tips?

Download this plugin using the plugin manager, the plugin is for sending HTTP notifications against any node.
In your command step/script step use the multiline data capture filter (to capture all the output in a single data variable like ${data.mydata}).
Now using the global variable step, take the data value (the job output) and create a global variable to export across the job or use in notifications, e.g: ${export.tonotify}.
In your job (creating or editing), go to the Notifications tab, select any scenario (e.g: On Success), clic on the + Add Notification button, select the "Http Notification" on the "Notification type" list, then put the HTTP URL, POST method and ${export.tonotify} on body section.
Take a look at this Job definition example for testing:
- defaultTab: nodes
description: ''
executionEnabled: true
id: fdda4e33-9121-4119-9685-69a18a0e1989
loglevel: INFO
name: HelloWorld
nodeFilterEditable: false
notification:
onsuccess:
plugin:
configuration:
authentication: None
body: ${export.tonotify}
contentType: application/json
method: POST
remoteUrl: https://your/url/to/post
timeout: '30000'
type: HttpNotification
notifyAvgDurationThreshold: null
plugins:
ExecutionLifecycle: null
scheduleEnabled: true
sequence:
commands:
- description: 'Any command / script / wathever, the ouput is captured by multiline
regex data capture filter'
exec: ls -a
plugins:
LogFilter:
- config:
hideOutput: 'false'
logData: 'true'
name: mydata
regex: ^(.*)
type: key-value-data-multilines
- configuration:
export: tonotify
group: export
value: ${data.mydata*}
description: create an export variable to notofy or use acroos your jobs
nodeStep: false
type: export-var
- description: just for debugging
exec: echo ${export.tonotify}
keepgoing: false
strategy: node-first
uuid: fdda4e33-9121-4119-9685-69a18a0e1989
Result (I used webhook.site to test).

Related

Playwright - JS - cucumber-html-report: Is there a way to display the Metadata and Scenarios without clicking the report?

I'm facing the next situation:
After the npm run report, The report is generated, but the metadata comes collapsed by default (The same with the Features and Scenarios)
Is there a way to show this expanded instead of collapsed by default?
And another question: Is it possible to generate this same report (expanded) in PDF?
I already tried with npx playwright pdf reports/cucumber_report.html report.pdf, but the report comes with the Metadata, Features and Scenarios collapsed (Impossible to expand in the same PDF )
This is my reporter file:
reporter.js
const reporter = require('cucumber-html-reporter')
// These options will be used at the time of HTML Report generation
const options = {
theme: 'bootstrap',
jsonFile: 'cucumber_report.json',
output: 'reports/cucumber_report.html',
reportSuiteAsScenario: true,
scenarioTimestamp: true,
launchReport: false,
metadata: {
'App Version': '1.0.0',
'Test Environment': 'TEST',
Browser: 'Chrome 107.0.5304.18',
Platform: 'MacOS Monterey - Version: 12.6',
},
}
reporter.generate(options)

Not getting SKIPPED test-cases in cucumber html report

I'm using "cucumber-html-reporter" for my Appium, Pytest-BDD automation. For some reason, I'm not getting skipped test cases in my html report.
Below is my report generation script
var reporter = require('cucumber-html-reporter');
var date = new Date().getTime()
var options = {
theme: 'bootstrap',
jsonFile: __dirname + '/reports/JsonReport.json',
output: __dirname + '/reports/htmlReport/report.html',
reportSuiteAsScenarios: true,
scenarioTimestamp: true,
launchReport: false,
metadata: {
"App Version": "app_version",
"Test Environment": "Local",
"Device": "DeviceName",
"Platform": "DevicePlatform",
"App-Instance-Id" : "appInstanceId"
}
};
reporter.generate(options);
I'm using #skip explicitly to skip the test cases. I want to see those cases in html report. I couldn't find any resource to solve this issue. Any help would be appreciated.
Below is my sample code
#fire #smoke #android #testCoupe
Feature: Fire Screen
Verifying Fire Screen Functionality
#skip
Scenario: Tapping on an news article under fire card
When Scroll to "SPOTLIGHT_FIRE_CARD" CARD
And The user has clicked on the "SPOTLIGHT_FIRE_CARD" button
Then The user can view "FIRE_STORY_ARTICLE" by clicking "FIRE_STORY_TITLE" in "FIRE_CENTER_SCREEN"
After automation run, I can't see any skip test cases, I can only see passed or failed test case.
My execution script
python3 -m pytest --disable-pytest-warnings -vv --gherkin-terminal-reporter --cucumberjson=$REPORT_PATH -k "fireTest" -s

Instagram MediaID/Shortcode to URL

I'm making a sequence of API calls to Instagram Graph API in order to publish an image.
As described in their docs I'm making two calls as follows:
POST https://graph.facebook.com/API_VERSION/IG_USER_ID/media
with params:
{
access_token: IG_USER_ACCESSTOKEN,
image_url: "https://cdn0.iconfinder.com/data/icons/social-media-square-4/1024/instagram-512.png",
caption: "Caption goes here",
}
returns:
{ id: 17859694922405416 }
Then I get the media container id from this call and I make another one to publish it:
POST https://graph.facebook.com/API_VERSION/IG_USER_ID/media_publish
with parameters:
{
creation_id: CONTAINER_ID_TAKEN_FROM_THE_PREVIOUS_CALL,
access_token: IG_USER_ACCESSTOKEN
}
This returns another ID which then I convert into a shortcode (using a function I found handy).
{
id: '17872941842175967',
id_str: '17872941842175967',
}
Result shortcode is : _f1iNmBff
I cannot seem to find the proper URL to see that image in the browser.
I've tried with: https://www.instagram.com/p/_f1iNmBff/, but it says that the page cannot be found.
I've even tried to check on the media container status with another call and it says that the status is FINISHED (but not PUBLISHED).
Any idea what the problem is?

Is there a way to retrieve the conversation history in Dialogflow?

Is there a way to obtain the full conversation between the user and agent. Pretty much similar to what I get by clicking the history tag but programmatically. The point is to save the interaction between user and agent as text.
Thank you guys in advanced!
There's no API to retrieve the history from Dialogflow directly. But what you can do is enable logging.
Agent Settings > General > Log Settings > Log interactions to Google Cloud
And all the interactions will be logged into Google Stackdriver, which has an API where you will be able to retrieve all the logs, and hence the chat history.
https://cloud.google.com/logging/docs/reference/v2/rest/
This is how the logs are stored in Stackdriver
{
insertId: "19ignahfzlu2o7"
labels: {
protocol: "V2BETA1"
request_id: "3033c2e3-7cab-4a00-b2b7-207be8d22366"
type: "dialogflow_request"
}
logName: "projects/dialogflowproject-ca57b/logs/dialogflow_agent"
receiveTimestamp: "2019-03-27T12:44:42.547531753Z"
resource: {
labels: {
project_id: "dialogflowproject-ca57b"
}
type: "global"
}
severity: "INFO"
textPayload: "Dialogflow gRPC Request : session: projects / dialogflowproject - ca57b / agent / sessions / 53 d451c1 - 40 f5 - c00e - cbbd - 178e ff32b971 "
query_params {
time_zone: "America/Buenos_Aires"
}
query_input {
text {
text: "hi"
language_code: "en"
}
}
"
timestamp: "2019-03-27T12:44:42.420Z"
trace: "53d451c1-40f5-c00e-cbbd-178eff32b971"
}
You can then retrieve the session from there, and build the whole chat history.
The other alternative is to save the interactions to a database when they are happening if the messages goes through your server first, which may not be your case.

FineUploader onComplete not firing with CoffeeScript

I'm creating my first project with FineUploader using Node.JS, Express, and CoffeeScript. Everything is working perfectly so far, with one exception. After the upload completes, I am returning a JSON object containing the success variable, as well as one other variable that is necessary to proceed. Unfortunately, I cannot successfully get the onComplete callback to fire. I believe all of my code is correct, and the Chrome console is not throwing any errors. I have also tried printing to the Chrome console in the onComplete method, but to no avail. Any assistance would be greatly appreciated.
uploader = new $("#collaboration-fine-uploader").fineUploader
autoUpload: false
multiple: false
validation:
allowedExtensions: ['pdf', 'doc', 'docx', 'ppt', 'pptx', 'xls', 'xlsx']
sizeLimit: 1024*1024*1024*10 # 10MB
text:
uploadButton: "<i class='icon-plus icon-white'></i> Select Files"
request:
endpoint: "/files/discussions/collaborations/upload"
callbacks:
onComplete: (id, fileName, responseJSON) ->
if (responseJSON.success)
alert "response success"
discussionId = responseJSON.discussionId
$.ajax
type: "GET"
url: "/courses/"+serverData.course._id+"/discussions/"+discussionId
beforeSend: (xhr) ->
xhr.setRequestHeader 'x-pjax', 'true'
success: (html) ->
# Replace the old html
$(".discussions-tab").html html
$(".new-discussion").slideUp()
$("#new-discussion-modal").deactivateModal()
# History push
window.history.pushState window.history.state, "Discussions", "/courses/"+serverData.course._id+"/discussions/"+discussionId
# Scroll to top
$.scrollTo 0
$(".trigger-upload-and-submit").on "click", (e) ->
e.preventDefault()
uploader.fineUploader "setParams",
discussion:
title: $(".new-collaboration .discussion-title").val()
body: $(".new-collaboration .discussion-body").val()
groupId: serverData.course._id
showProfessors: $(".new-collaboration .show-professor-checkbox").attr("checked")
showStudents: $(".new-collaboration .show-students-checkbox").attr("checked")
type: "Collaboration"
uploader.fineUploader("uploadStoredFiles")
Check the jQuery section of the documentation.
You need to listen for the 'complete' event if you are using the jQuery plugin.
uploader.on 'complete', (id, fileName, responseJSON) ->
if (responseJSON.success)
// Other code

Resources