UNPKG

generate-atm-test-cycle

Version:

npm module to create a new test cycle in Adaptavist test management tool

53 lines (51 loc) 2.8 kB
require('dotenv').config(); const req = require('request'); var fs = require('fs'); var BASE_URL = process.env.BASE_URL || null; USERNAME = process.env.JIRA_USERNAME || null; PASSWORD = process.env.JIRA_PASSWORD || null; PROJECT_KEY = process.env.PROJECT_KEY || null; TEST_CYCLE_NAME = process.env.TEST_CYCLE_NAME || "Regression | " + new Date().toLocaleString(); TEST_PLAN_KEY = process.env.TEST_PLAN_KEY || null; TEST_CYCLE_STATUS = process.env.TEST_CYCLE_STATUS || null; TEST_CYCLE_ITERATION = process.env.TEST_CYCLE_ITERATION || null; TEST_CYCLE_VERSION = process.env.TEST_CYCLE_VERSION || null; TEST_CYCLE_FOLDER = process.env.TEST_CYCLE_FOLDER || null; TEST_CYCLE_ISSUE_KEY = process.env.TEST_CYCLE_ISSUE_KEY || null; TEST_CYCLE_OWNER = process.env.TEST_CYCLE_OWNER || null; TEST_CYCLE_PLANNED_START_DATE = process.env.TEST_CYCLE_PLANNED_START_DATE || null; TEST_CYCLE_PLANNED_END_DATE = process.env.TEST_CYCLE_PLANNED_END_DATE || null; /** * This method will create a new test cycle in ATM **/ function createTestCycle(){ var atmCycleRequest = { uri: 'https://' + USERNAME + ':' + PASSWORD + '@' + BASE_URL + '/rest/atm/1.0/testrun', method: 'POST', json: { "name": TEST_CYCLE_NAME, "projectKey": PROJECT_KEY, "testPlanKey": TEST_PLAN_KEY, "status": TEST_CYCLE_STATUS, "iteration": TEST_CYCLE_ITERATION, "version": TEST_CYCLE_VERSION, "folder": TEST_CYCLE_FOLDER, "issueKey": TEST_CYCLE_ISSUE_KEY, "owner": TEST_CYCLE_OWNER, "plannedStartDate": TEST_CYCLE_PLANNED_START_DATE, "plannedEndDate": TEST_CYCLE_PLANNED_END_DATE } }; req(atmCycleRequest, function (error, response, body) { if (response.statusCode === 200 || response.statusCode === 201){ process.env.TEST_CYCLE_ID = body.key; console.log('New Test Cycle ============> ' + body.key); //Outputs the generated cycle id to console var wstream = fs.createWriteStream('cycleID.txt'); wstream.write(body.key); }else { console.log('Test Cycle not created. Error Code --> ' + response.statusCode);// Outputs the error code to console console.log('Error ============> ' + error); // Outputs the error message to console } }); } module.exports.createTestCycle = createTestCycle;