SHARE
TWEET

NodeJS Jira Worklog Import

a guest Oct 5th, 2017 17 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var request = require('request'),
  2.     fs      = require('fs');
  3.  
  4. var filename = 'testimport.csv',
  5.     issue    = 'TODO-421',
  6.     user     = 'username',
  7.     password = 'password';
  8.  
  9. var lines = fs.readFileSync(filename, 'utf-8').toString().trim().split('\r\n');
  10.  
  11. lines.forEach(function(line) {
  12.     var values = line.split(';');
  13.     request({
  14.             method: 'POST',
  15.             uri:    'http://itz-jira:8080/rest/api/2/issue/' + issue + '/worklog',
  16.             json:   {
  17.                 'comment':          values[2],
  18.                 'started':          values[1],
  19.                 'timeSpentSeconds': values[0]
  20.             }
  21.         },
  22.         function(err, res, body) {
  23.             if(err) {
  24.                 console.log(err);
  25.             }
  26.         }).auth(user, password);
  27. });
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top