How to send a notification when a unit test fails? - groovy

I use the following function within a Jenkins pipeline in order to process unit test results and display them in the Jenkins build page:
def check_test_results(String path) {
step([
$class: 'XUnitBuilder',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '0', failureThreshold: '0', unstableNewThreshold: '', unstableThreshold: ''],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
],
tools: [
[$class: 'JUnitType', deleteOutputFiles: true, failIfNotNew: false, pattern: path, skipNoTestFiles: false, stopProcessingIfError: true]
]
])
}
I'm aware to the fact that the J/Xunit results are displayed in the Jenkins build page but I want to have the ability to send a Slack notification (slack notifications are already configured and working) if a unit test fails and more importantly when it fails, is that possible?

You can use a try/catch for this for the suite of unit tests, but perhaps not individually.
def check_test_results(String path) {
try {
step([
$class: 'XUnitBuilder',
testTimeMargin: '3000',
thresholdMode: 1,
thresholds: [
[$class: 'FailedThreshold', failureNewThreshold: '0', failureThreshold: '0', unstableNewThreshold: '', unstableThreshold: ''],
[$class: 'SkippedThreshold', failureNewThreshold: '', failureThreshold: '', unstableNewThreshold: '', unstableThreshold: '']
],
tools: [
[$class: 'JUnitType', deleteOutputFiles: true, failIfNotNew: false, pattern: path, skipNoTestFiles: false, stopProcessingIfError: true]
]
])
}
catch(error) {
slackSend message: error
}
}
and customize the Slack notification to your liking.

Related

Chat base session flow not showing flow correctly

I have created some messages in chatbase using session_id to divide sessions. However, these are not shown as separate flows. They appear as concatenated flows.
Example messages:
[ { api_key: 'xxxx',
type: 'user',
user_id: 'Lee',
time_stamp: 1559340845342,
platform: 'Chat_Test2',
session_id: '200',
message: '_',
intent: 'choice',
not_handled: 'false',
version: '1.1' },
{ api_key: 'xxxx',
type: 'agent',
user_id: 'Lee',
time_stamp: 1559340845341,
platform: 'Chat_Test2',
session_id: '200',
message: 'what_would_you_like',
version: '1.1' } ]
[ { api_key: 'xxxx',
type: 'user',
user_id: 'Lee',
time_stamp: 1559340848284,
platform: 'Chat_Test2',
session_id: '201',
message: 'hello',
intent: 'Welcome',
not_handled: 'false',
version: '1.1' },
{ api_key: 'xxxx',
type: 'agent',
user_id: 'Lee',
time_stamp: 1559340848283,
platform: 'Chat_Test2',
session_id: '201',
message: 'hello_how_can_I_help',
version: '1.1' } ]
Thank you for your question and providing the example JSON payload. I see that are numbering your session id's sequentially. You will need to label each utterance with a given session with the same session id. The utterances within each session will then be sorted by timestamp.
If you continue to experience issues, please contact chatbase-support#google.com with your bot's api key and I will be happy to look into your issue directly.

Button alignment in Adaptive cards

I was wondering if there is a way to control alignment of buttons in Adaptive card in Bot Emulator.
I tried the same code in the emulator, and the Microsoft Visualizer, but they render differently. Here are the images: Emulator Visualizer
Here's the code I've used:
{
"contentType": "application/vnd.microsoft.card.adaptive",
"content": {
'$schema': 'http://adaptivecards.io/schemas/adaptive-card.json',
'version': '1.0',
'type': 'AdaptiveCard',
'body': [
{
'type': 'TextBlock',
'text': 'Meeting Title',
'weight': 'bolder'
},
{
'type': 'TextBlock',
'text': 'Location',
'separator': true,
'isSubtle': true,
'size': 'small'
},
{
'type': 'TextBlock',
'text': 'Location',
'spacing': 'none'
},
{
'type': 'TextBlock',
'text': 'Organizer',
'separator': true,
'isSubtle': true,
'size': 'small'
},
{
'type': 'TextBlock',
'text': 'Organizer Name',
'spacing': 'none'
},
{
'type': 'TextBlock',
'text': 'Start Time',
'separator': true,
'isSubtle': true,
'size': 'small'
},
{
'type': 'ColumnSet',
'spacing': 'none',
'columns': [
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': '05:00 PM',
'isSubtle': false,
'weight': 'bolder'
}
]
},
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': 'May 21'
}
]
},
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': '2017',
'isSubtle': true,
'weight': 'bolder'
}
]
}
]
},
{
'type': 'TextBlock',
'text': 'End Time',
'separator': true,
'isSubtle': true,
'size': 'small'
},
{
'type': 'ColumnSet',
'spacing': 'none',
'columns': [
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': '05:30 PM',
'isSubtle': false,
'weight': 'bolder'
}
]
},
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': 'May 21'
}
]
},
{
'type': 'Column',
'width': 'auto',
'items': [
{
'type': 'TextBlock',
'text': '2017',
'isSubtle': true,
'weight': 'bolder'
}
]
}
]
}
],
'actions': [
{
'type': 'Action.Submit',
'title': 'Accept',
'data':{
'accept': true
}
},
{
'type': 'Action.Submit',
'title': 'Decline',
'data':{
'accept': false
}
}
]
}
}
As seen, the buttons are aligned horizontally in the emulator, and next to each other in the visualizer. Is there a way to modify the height and width of the buttons, as well as the way they are aligned?
I was wondering if there is a way to control alignment of buttons in
Adaptive card in Bot Emulator.
Short answer is "No". You cannot modify the render of components in the Emulator.
Long answer is: Bot Framework Emulator is open-source, so you can try to modify and run locally your custom emulator. But I'm not sure that making a custom render on the emulator is very useful for real projects, as they will not run on the emulator.
Emulator sources are located here: https://github.com/Microsoft/BotFramework-Emulator
There is something called Hostconfig with Adaptive cards, try using that. Have shared the editor tool link.

after docusign custom tab update auto font change

I'm trying to implement embeded signing using docusign, where we have two different recipients. After the first recipient signs, I'm updating custom tab values for the second recipient which is working as expected.
The issue is after the tabs are updated their fonts getting auto changed.
After the update I did list the tab properties, both (updated and the original) have same properties.
original:
{
height: 11,
validationPattern: '',
validationMessage: '',
shared: 'false',
requireInitialOnSharedChange: 'false',
requireAll: 'false',
name: 'xxxx',
value: 'xxxx',
originalValue: 'xxxx',
width: 102,
required: 'true',
locked: 'true',
concealValueOnDocument: 'false',
disableAutoSize: 'false',
maxLength: 4000,
tabLabel: 'xxxx',
font: 'lucidaconsole',
fontColor: 'black',
fontSize: 'size12',
documentId: '1',
recipientId: '1',
pageNumber: '1',
xPosition: '252',
yPosition: '323',
tabId: 'xxxx',
templateLocked: 'false',
templateRequired: 'false' }
updated:
{
height: 11,
isPaymentAmount: 'false',
validationPattern: '',
validationMessage: '',
shared: 'false',
requireInitialOnSharedChange: 'false',
requireAll: 'false',
name: 'xxxx',
value: 'xxxx',
originalValue: 'xxxx',
width: 102,
required: 'true',
locked: 'true',
concealValueOnDocument: 'false',
disableAutoSize: 'false',
maxLength: 4000,
tabLabel: 'xxxx',
font: 'lucidaconsole',
bold: 'false',
italic: 'false',
underline: 'false',
fontColor: 'black',
fontSize: 'size12',
documentId: '1',
recipientId: '2',
pageNumber: '1',
xPosition: '251',
yPosition: '337',
tabId: 'xxxx',
templateLocked: 'false',
templateRequired: 'false' }
The various update methods in the DocuSign eSignature REST API are update methods, not patch methods.
Therefore, when you call an update method, you need to supply all of the object's parameters, using either the current value or your updated value for the parameters.
If you don't know the object's current values, first do a get operation.

Watch node.js object variable in WebStorm debugger

I have a node.js object variable.
var json_sample =
{
'81': { length: '2', data: [ '11', '22' ] },
'82': { length: '1', data: [ 'ab' ] },
'83': { length: '2', data: [ '21', 'ac' ] },
'84': { length: '3', data: [ 'af', 'de', 'ad' ], }
};
When I do console.log(json_sample ), I can see the printed output.
However, when I want to use WebStorm debugger to view the object contents, I cannot see the content values. All I see is some properties of __proto__ which are not useful for my debugging.
Is this a limitation of WebStorm debugger in not being able to view object contents? Is one limited to using console.log() for debugging objects?
Look at the screenshot: it looks for me like this in the WebStorm 11.0.3 as well as WebStorm 2016.1
Could you provide a full code example?
For some reason, Webstorm debugger cannot show the object if the property name is a number.
This will not work on Webstorm.
var json_sample =
{
'81': { length: '2', data: [ '11', '22' ] },
'82': { length: '1', data: [ 'ab' ] },
'83': { length: '2', data: [ '21', 'ac' ] },
'84': { length: '3', data: [ 'af', 'de', 'ad' ], }
};
To show the object on Webstorm debugger, make this change.
var json_sample =
{
'aa': { length: '2', data: [ '11', '22' ] },
'bb': { length: '1', data: [ 'ab' ] },
'cc': { length: '2', data: [ '21', 'ac' ] },
'dd': { length: '3', data: [ 'af', 'de', 'ad' ], }
};

Google API returns incorrect values

I want the goal completions by page from the Analytics API. The dates are the same, and sampling is off.
API:
{ kind: 'analytics#gaData',
id: 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:90090243&dimensions=ga:hostname,+ga:pagePath&metrics=ga:users,ga:goalCompletionsAll,ga:goalValueAll&start-date=2015-01-05&end-date=2015-01-05',
query:
{ 'start-date': '2015-01-05',
'end-date': '2015-01-05',
ids: 'ga:90090243',
dimensions: 'ga:hostname, ga:pagePath',
metrics: [ 'ga:users', 'ga:goalCompletionsAll', 'ga:goalValueAll' ],
'start-index': 1,
'max-results': 1000,
samplingLevel: 'HIGHER_PRECISION' },
itemsPerPage: 1000,
totalResults: 10,
selfLink: 'https://www.googleapis.com/analytics/v3/data/ga?ids=ga:12345678&dimensions=ga:hostname,+ga:pagePath&metrics=ga:users,ga:goalCompletionsAll,ga:goalValueAll&start-date=2015-01-05&end-date=2015-01-05',
profileInfo:
{ profileId: '12345678',
accountId: '12345678',
webPropertyId: 'UA-12345678-1',
internalWebPropertyId: '12345678',
profileName: 'All Web Site Data',
tableId: 'ga:90090243' },
containsSampledData: false,
columnHeaders:
[ { name: 'ga:hostname',
columnType: 'DIMENSION',
dataType: 'STRING' },
{ name: 'ga:pagePath',
columnType: 'DIMENSION',
dataType: 'STRING' },
{ name: 'ga:users', columnType: 'METRIC', dataType: 'INTEGER' },
{ name: 'ga:goalCompletionsAll',
columnType: 'METRIC',
dataType: 'INTEGER' },
{ name: 'ga:goalValueAll',
columnType: 'METRIC',
dataType: 'CURRENCY' } ],
totalsForAllResults:
{ 'ga:users': '155',
'ga:goalCompletionsAll': '0',
'ga:goalValueAll': '0.0' },
rows:
[ [ 'mydomain.com', '/', '1', '0', '0.0' ],
[ 'mydomain.com',
'/brand-business-bundle',
'1',
'0',
'0.0' ],
[ 'mydomain.com',
'/brand-business-internet',
'1',
'0',
'0.0' ],
[ 'mydomain.com', '/business-bundle', '1', '0', '0.0' ],
[ 'mydomain.com',
'/business-fiber-internet',
'22',
'0',
'0.0' ],
[ 'mydomain.com', '/business-internet', '37', '0', '0.0' ],
[ 'mydomain.com', '/business-phone', '84', '0', '0.0' ],
[ 'mydomain.com', '/privacy-policy', '1', '0', '0.0' ],
[ 'mydomain.com',
'/small-business-internet',
'6',
'0',
'0.0' ],
[ 'co.lumb.co', '/', '1', '0', '0.0' ] ] }
Here's what I see in the Analytics dashboard:
Things I have tried:
Different sampling levels (no effect)
Removing other dimensions from the query (total is correct, but I want per-page data)
Different dates (no effect)
Why am I getting back such low values from the API when the dashboard shows otherwise?
The most befuddling thing about this was that it worked for about 2 months and suddenly broke. I suspect a bug was introduced to the Analytics API.
The workaround is to use ga:goalCompletionLocation instead of ga:pagePath. I call it a workaround instead of a solution because you cannot combine ga:goalCompletionLocation with much else as far as metrics go.

Resources