How to integrate cypress slack notifications using reportportal results? - javascript

I tried to integrate cypress and slack. I'm able to get simple notifications such as pipeline status, alert, push or merge request. My requirement is to get notification like this.
Also I'm not able to integrate reportportal, I need to get more detailed for slack notification.
I tried to follow these instructions
My cypress.json file look like this.
"reporterOptions": {
"configFile": "reporterOpts.json",
"reporterEnabled": "spec, mocha-junit-reporter, #reportportal/agent-js-cypress, mochawesome",
"reportportalAgentJsCypressReporterOptions": {
"endpoint": "https://reportportal.mlsdevcloud.com/api/v1/",
"token": "445151-w6djb-ae48-awd86wd",
"launch": "no launch",
"project": "demo",
"description": "UAT",
"autoMerge": true
},
"mochaJunitReporterReporterOptions": {
"mochaFile": "cypress/results/results-[hash].xml"
}
},
"reports": [
{
"targets": [
{
"name": "slack",
"inputs": {
"url": "https://hooks.slack.com/services/T/secreatToken/"
}
}
],
"results": [
{
"type": "junit",
"files": ["cypress/results/results-[hash].xml"]
}
]
}
]
And this is suggested json file.
{
"reports": [
{
"targets": [
{
"name": "teams",
"inputs": {
"url": "<teams-incoming-webhook-url>"
},
"extensions": [
{
"name": "report-portal-analysis",
"inputs": {
"url": "<report-portal-base-url>",
"api_key": "<api-key>",
"project": "<project-id>",
"launch_id": "<launch-id>"
}
}
]
}
],
"results": [
{
"type": "testng",
"files": ["path/to/testng-results.xml"]
}
]
}
]
}
how to pass
"launch_id": ""
it is generated every time when build is triggered.

Related

Apply custom colors to only specific output channel

How can I add custom colors to only output channel created by my extension?
Currently I have this package.json
{
"name": "mytestextension-output-colors",
"displayName": "My test extension - output colors",
"version": "0.0.1",
"publisher": "nobody",
"engines": {
"vscode": "^1.72.0"
},
"main": "./extension.js",
"activationEvents": [
"onStartupFinished"
],
"contributes": {
"languages": [
{
"id": "mytestextension-output",
"aliases": [],
"mimetypes": [
"text/x-code-output"
]
}
],
"grammars": [
{
"language": "mytestextension-output",
"scopeName": "text.mytestextension-output",
"path": "./mytestextension-output.tmLanguage.json"
}
],
"configuration": {
"type": "object",
"title": "My Test Extension - output colors"
},
"configurationDefaults": {
"editor.tokenColorCustomizations": {
"textMateRules": [
{
"scope": "mytestextension-output-red",
"settings": {
"foreground": "#f00080"
}
}
]
}
}
}
}
extension.js
const window = require("vscode").window;
function activate() {
const out = window.createOutputChannel("myextension test output", "mytestextension-output");
out.appendLine(`red output`);
}
function deactivate() {}
module.exports = {
activate,
deactivate
};
mytestextension-output.tmLanguage.json
{
"$schema": "https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json",
"name": "mytestextension-output",
"scopeName": "text.mytestextension-output",
"patterns": [ {
"match": ".*",
"name": "mytestextension-output-red"
}
]
}
Even though the grammar is set for mytestextension-output id/scope, it applied to and changes color to red in all output channels (git, tasks, extensions, etc)
What am I missing here?
Gist example

ExpressJS - Swagger - Swagger not working when I Added Bearer Authorization Header

I've defined the security definitions.
"securityDefinitions": {
"Bearer": {
"type": "apiKey",
"in": "header",
"name": "Authorization"
}
},
And this is my path :
"/post/user": {
"get": {
"tags": [
"Authenticated User"
],
"summary": "All User's Posts",
"description": "",
"operationId": "user-posts",
"produces": [
"application/json"
],
"responses": {
"200": {
"description": "All user's posts.",
"schema": {
"type": "object",
"properties": {
"data": {
"type": "array",
"items": {
"$ref": "#/definitions/Post"
}
}
}
}
}
},
"security": {
"Bearer": []
}
}
},
This is how I initialize my swagger-ui-express :
const swaggerUi = require('swagger-ui-express');
const swaggerDocument = require('./swagger.json');
app.use('/api-docs', swaggerUi.serve, swaggerUi.setup(swaggerDocument));
When I tried to login and add the token to the Authorize option in the top right and executed the protected path, Swagger will be loading forever. Even Swagger is not hitting the endpoint because there is no log printed in the server console.
Do you have any idea about this?

How to send email using azure JavaScript function?

its my index.js file code.which i have taken a refrence from this link Javascript Azure Function to send email using SendGrid
module.exports = async function (context, req) {
var message = {
"personalizations": [ { "to": [ { "email": "testto#gmail.com" } ] } ],
from: { email: "testfrom#gmail.com" },
subject: "Azure news",
content: [{
type: 'application/json',
value: req.body.to
}]
};
context.done(null, {message});
};
This is the function.json file code.
{
"bindings": [
{
"authLevel": "anonymous",
"type": "httpTrigger",
"direction": "in",
"name": "req",
"methods": [
"get",
"post"
]
},
{
"name": "$return",
"type": "sendGrid",
"direction": "out",
"apiKey" : "SG.O1pazBKvS5Ox4YExYCY...",
"to": "df#mail.com ",
"from": "gh#gmail.com",
"subject": "SendGrid output bindings"
}
]
}
This is root directory local.setting.json file.
{
"IsEncrypted": false,
"Values": {
"AzureWebJobsStorage": "",
"FUNCTIONS_WORKER_RUNTIME": "node",
"SENDGRID_API_KEY": "SG.O1pazBKvS5Ox4YExYCY...."
}
}
This is root directory host.json file
{
"version": "2.0",
"extensions": {
"sendGrid": {
"from": "Azure Functions <samples#functions.com>"
}
}
}
Following error i am getting in the console. Also , what is the correct way to send this email.? Reference taken for configuration file https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-sendgrid
Looks like you don't have the binding extension installed. You could either
Use Extension Bundles by updating your host.json to something like this
{
"version": "2.0",
"extensionBundle": {
"id": "Microsoft.Azure.Functions.ExtensionBundle",
"version": "[1.*, 2.0.0)"
},
"extensions": {
"sendGrid": {
"from": "Azure Functions <samples#functions.com>"
}
}
}
Install the function extension using the dotnet CLI (Would need .NET Core installed locally)
dotnet add package Microsoft.Azure.WebJobs.Extensions.SendGrid --version 3.0.0

Json data from Rest service documentation has slash in its keys

Im trying to build a dashboard of apis that are used within my company to centralize and give examples and documentation. The data that I need to display has / slashes in it and cant figure out how to step into it.
data.paths/api/IDCard??
I tried escaping the slashes, I tried converting the data, I tried using ./
'/' not sure what else to do
{
"swagger": "2.0",
"info": {
"version": "v1",
"title": "IDCardRequest"
},
"host": "fasoa-prd1.corp.wpsic.com",
"basePath": "/IDCardRequest",
"schemes": [
"https"
],
"paths": {
"/api/IDCard": {
"get": {
"tags": [
"IDCard"
],
"operationId": "IDCard_Get",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object"
}
}
}
},
"post": {
"tags": [
"IDCard"
]
}
}
}
}
keep getting undefined. I want the value for the specific key that I am referencing
You can reach property data.paths["/api/IDCard"] like this.
There is a sample here.
var value = {
"paths": {
"/api/IDCard": {
"get": {
"tags": [
"IDCard"
],
"operationId": "IDCard_Get",
"consumes": [],
"produces": [
"application/json",
"text/json",
"application/xml",
"text/xml"
],
"responses": {
"200": {
"description": "OK",
"schema": {
"type": "object"
}
}
}
},
"post": {
"tags": [
"IDCard"
]
}
}
}
}
console.log(value.paths["/api/IDCard"].get.tags)
Assuming the above object is in data,Try accessing it as follows
dataInsideGet = data.paths["/api/IDCard"]["get"]
dataInsidePost = data.paths["/api/IDCard"]["post"]
console.log(dataInsideGet) // Your desired object
Whenever you have Object keys with special characters, you should be using the array notation to access the objects.
More about Property Accessors here
Hope it helps!

.openDialog() method doesnt load page in TFS 2017

I have a button on 2017 TFS work item form. It should open a dialog.
I used this Microsoft documentation (https://learn.microsoft.com/en-us/vsts/extend/develop/using-host-dialog) and made the following code:
$(us_button[0]).click(function(){
VSS.getService(VSS.ServiceIds.Dialog).then(function(dialogService) {
var extensionCtx = VSS.getExtensionContext();
// Build absolute contribution ID for dialogContent
var contributionId = extensionCtx.publisherId + "." + extensionCtx.extensionId + ".info";
// Show dialog
var dialogOptions = {
title: "My Dialog",
width: 800,
height: 600
};
dialogService.openDialog(contributionId, dialogOptions);
});
});
I also added an info element in manifest as Microsoft’s guide suggests.
It does open a window, but never loads the page info.html.
The only thing debug says is (no stack) null.
Manifest file:
{
"manifestVersion": 1,
"id": "usButton",
"version": "1.0.56",
"name": "usButton",
"publisher": "Logrocon",
"icons": {
"default": "img/logo.png"
},
"targets": [
{
"id": "Microsoft.VisualStudio.Services"
}
],
"tags": [
"Work Item",
"Work Item control"
],
"files": [
{
"path": "img",
"addressable": true
},
{
"path": "dist",
"addressable": true
},
{
"path": "scripts/main.js",
"contentType": "text/javascript",
"addressable": true
},
{
"path": "info.html",
"addressable": true
},
{
"path": "usButton.html",
"addressable": true
}
],
"categories": [
"Plan and track"
],
"scopes": [
"vso.work_write"
],
"contributions": [
{
"id": "usButton",
"type": "ms.vss-work-web.work-item-form-control",
"targets": [
"ms.vss-work-web.work-item-form"
],
"properties": {
"name": "usButton",
"uri": "usButton.html",
"height": 40,
"inputs": [
{
"id": "FieldAppTestBtn",
"description": "Autocalculate Remaining Work.",
"type": "WorkItemField",
"properties": {
"workItemFieldTypes": ["Double"]
},
"validation": {
"dataType": "String",
"isRequired": true
}
}
]
}
},
{
"id": "info",
"targets": [],
"description": "The content to be displayed in the dialog",
"type": "ms.vss-web.control",
"properties": {
"uri": "info.html"
}
}
]
}
You didn't import the extension SDK and run VSS.init() method in the info.html. Update it to below and then try again:
<!DOCTYPE html>
<html style="background-color:inherit;height:100%;">
<head>
<title>Continious delivery actions</title>
<script src="dist/VSS.SDK.min.js"></script>
</head>
<body style="background-color:inherit;height:100%;">
<div><table><tr><td>ID</td><td>Поле</td><td>Значение</td></tr></table></div>
<script>
VSS.init();
</script>
</body>
</html>

Categories

Resources