const fetch = require("node-fetch"); export class Jiralogger{ static async logJira(stepName : string, scenarioName : string ,ModuleName:string, errorStack : string){ var setupName=""; if(process.env.SETUP==="USPROD"||process.env.SETUP==="UKPROD"||process.env.SETUP==="AUSPROD"||process.env.SETUP==="SGPROD") { setupName="Prod"; } const bodyData = `{ "fields": { "project": { "key": "DDS" }, "summary": "`+scenarioName+`--- SCENARIO failed from MODULE---`+ModuleName+`--- on STEP ---`+stepName+`", "components":[{"name": "`+process.env.PRODUCT_COMPONENT+`"}], "assignee": { "accountId": "5b8946017c582d2b86e246df" }, "description": "`+((errorStack.replace(/\\/g,"\\\\")).replace(/\"/g, "\\\"")).replace(/\n/g,"")+`", "issuetype": { "name": "Bug" }, "customfield_10128": { "value": "`+process.env.PRODUCT+`" }, "customfield_15709": { "value": "`+process.env.PRIORITY+`" }, "customfield_15606": { "value": "`+process.env.SEVERITY+`" }, "customfield_16203": { "value": "Yes" }, "customfield_16900": { "value": "`+setupName+`" }, "customfield_10402": { "value": "Automation" } } } `; console.log("heloooooooooooooooooo"+bodyData) fetch('https://pdtzycus.atlassian.net/rest/api/2/issue', { method: 'POST', headers: { // 'Authorization': `Basic cnVzaGFiaC5zaGFoQHp5Y3VzLmNvbTowYlVhMGNJN3oxR3h2SlR5V0ZqTEM1NDA`, 'Authorization': `Basic SklSQS1ib3R1c2VyQHp5Y3VzLmNvbTpRbnhXTVRKd0pQc0Q4aGpNMFdoVjlENTM=`, 'Accept': 'application/json', 'Content-Type': 'application/json' }, body: bodyData }) .then(async function(response : any) { console.log( `Response: ${response.status} ${response.statusText}` ); return response.text(); }) .then(async function(text : any){ console.log(text)}) .catch(async function(err : any){console.error(err)}); } }