floralvikings / jira-connector Goto Github PK
View Code? Open in Web Editor NEWNodeJS Wrapper for the Jira REST API
Home Page: http://floralvikings.github.io/jira-connector/
License: MIT License
NodeJS Wrapper for the Jira REST API
Home Page: http://floralvikings.github.io/jira-connector/
License: MIT License
The fix implemented for issue #18 breaks transitioning fields.
Before I was able to also change the Resolution of the ticket. After the change it only allows it to change the status.
transition: {
transition: {id: 5},
fields: {resolution: {name: 'Duplicate'}},
update: {
comment: [{add: {body: util.format(CLOSEREASON.Duplicate, dupe_of)}}]
}
}
This changes the status to Resolved, Resolution to Duplicate and adds a comment.
After the change:
{
transition: {id: 5},
fields: {resolution: {name: 'Duplicate'}},
update: {
comment: [{add: {body: util.format(CLOSEREASON.Duplicate, dupe_of)}}]
}
}
Fields and Update get ignored, I see no way to do them.
Hi there,
Non-coder here trying to dig into this stuff, and I'm pretty lost. I was able to write code to return values for a single issue, but I can't seem to find the right resources to write the code to return values based upon a JQL search. I tried something basic here, but I'm not sure what I'm doing wrong. Any guidance would be much appreciated, it would be huge to get this working for my company!
var JiraClient = require('jira-connector');
var jira = new JiraClient( {
host: (removed for security purposes),
basic_auth: {
base64: (removed for security purposes)
}
});
jira.search.search({
jql: 'type = bug'
}).then(issues => {
// list issues for your search
function(error, issue) {
console.log(issue.fields.issueKey, issue.fields.issuetype.name, issue.fields.summary, issue.fields.status.name, issue.fields.resolution.name, issue.fields.labels, issue.fields.customfield_12600, issue.fields.customfield_14212, issue.fields.customfield_10009, issue.fields.customfield_14200, issue.fields.customfield_14205, issue.fields.customfield_14203, issue.fields.customfield_14204, issue.fields.customfield_10004);
}
});
Please update the docs to reflect the latest changes. The existing docs on the mentioned site is still at version 1.11.0 whereas the latest release is 2.7.0
Hi, would you consider supplying also .d.ts files with your project in order to enable Intelisense support during development? It would also allow to type-check files during compilation. Thanks!
Here is some additional info : http://definitelytyped.org/guides/contributing.html
Marcin
Why 'getSprintsForBoard' method isn`t implemented? It is in documentation
On working with the npm module, i find out that there is a small syntax error at the uri which returns 404 on executing
Function "getBoard" is member of the AgileBoardClient but doesn't build an AgileUrl
@ line 58:
is written -- uri: this.jiraClient.buildURL('/board/' + opts.boardId),
must be --- uri: this.jiraClient.buildAgileURL('/board/' + opts.boardId),
This commit adds the expand param ea53fd8 but that causes an authentication issue when hitting jira.
This is because the docs say to provide an expand object. This is similar to getIssue but it gets iterated and parsed into a string over there. https://github.com/floralvikings/jira-connector/blob/master/api/issue.js#L995
The user methods do not have a buildRequestOptions function so I've fixed this by just iterating over the expand fields in the getUser function. https://github.com/rjgoldsborough/jira-connector/tree/fix-user-expand.
Let me know if you'd prefer a buildRequestOptions in the user file or maybe it's time to move it to the jiraClient file like the makeRequest function.
can NOT use this as jira.issue... :
jira.project.getProjectProperties
right now, create project is not supported, can someone please add to this?
Whenever i call the search method and pass along jql and fileds, i get a undefined.
Here the call:
jira.search.search({jql: 'issuetype in(Story,Bug,Issue) AND status not in("Resolved","Closed") AND sprint in openSprints()', fields: 'summary,status' }, function(err, res) { console.log(res);});
Whenever i omit the 'fields' option, it works like a charm.
Hi,
Nice connector by the way - This may not really an issue in terms of your connector, but I am connecting to a dev and prod instance of Jira internally and have the following challenges with certs:
If I have a copy of the intermediate cert is there a way to point the connector to the location of the cert in order for it to use it in the connection?
I will try a global variable, but I don't know if it will work either: process.env.NODE_TLS_REJECT_UNAUTHORIZED = '0'
Thanks
Andrew
The following code does not permit a user to be unassigned.
this.assignIssue = function (opts, callback) {
if (!opts.assignee) {
throw new Error(errorStrings.NO_ASSIGNEE_ERROR);
}
var options = this.buildRequestOptions(opts, '/assignee', 'PUT', {name: opts.assignee});
this.jiraClient.makeRequest(options, callback, 'Issue Assigned');
};
The user can be unassigned by setting the value of assignee
to null
.
I use component.createComponent from jiraClient and need utf-8 for some german characters in the description (ä, ü, ö, ...)
How can i do this?
Hey guys,
I'm running a jira request for each issue of an object, having timing issues with it, I'm not an expert with promises so I was wondering if you can point me in the right direction
var issuesObject = ''
for (i = 0; i < issuesObject.length; i++) {
jira.issue.getIssue({
issueKey: 'SQA-72'
}, function(error, issue) {
issuesDescription += issue.fields.summary;
});
});
console.log('run second function with issues description variable');
Basically my console log is running before the jira function, I need to wait until the jira response to run my function but can't do it inside the loop.
Any idea?
Thanks in advance.
Hello!
Awemose library, just found it one hour ago and it's amazing! Congratulations for the good job.
I'm having a problem when adding an attachment for an Issue, and I don't know why. I get something like:
{ Error: form-data: ENOENT: no such file or directory, open 'C:\Users\Marcos\projects\mycurrentproject\__1496158180441.json'
errno: -4058,
code: 'ENOENT',
syscall: 'open',
path: 'C:\\Users\\Marcos\\projects\\mycurrentproject\\__1496158180441.json' }
But the path is correct and the file exists, any ideas?
Right I see there was privilege to fetch a particular issue by passing its key , where as how would i fetch
the list of total issues from the selected project ? referred official API documentation but no luck , is there any such privilege , please suggest me ..
getIssuesForBacklog does not supporting some parameters (fields, sql, validateQuery) per
https://developer.atlassian.com/cloud/jira/software/rest/#api-board-boardId-backlog-get
The change needed is just to pass through the parameters similar to how it is done for api/sprint.js/getSprintIssues:
qs: {
startAt: opts.startAt,
maxResults: opts.maxResults,
jql: opts.jql,
validateQuery: opts.validateQuery,
fields: opts.fields
}
Hello; I am stuck at the "oauth_problem=signature_invalid", trying to connect with JIRA Cloud. Before I spend hours digging in, can someone confirm that floralvikings/jira-connector (and really, the OAuth module underneath) works correctly with JIRA Cloud?
I can connect and get good responses from the requests. Very nice library by the way.
However, I am trying to figure out if there is a way to get all issues, or all issues for a given sprint.
I did not see any Sprint or RapidView clients in the code. Is this possible?
If not is there a way I can go about this with this library?
Thanks in advance.
This is more of a question but I was curious why you chose to use tough-cookie-filestore over a straight request jar.
I mostly ask because tough-cookie-filestore is outdated and I am having trouble getting tough-cookie working but a straight request.jar() seems to work fine.
Thanks in advance.
Hello,
I'm trying to do this
jira.issue.setProperty({ id, propertyKey, propertyValue }, cb)
In order to move an issue from one column to another. However it doesn't, and I can see the properties I set like this remain as some kind of custom properties that don't affect the actual issue. Which propertyKey/propertyValue could I use to do this?
Thanks
According to the JIRA docs, some of the filter- / query params are optional. But in the library you have to pass them in, even if they are null.
For Example:
https://docs.atlassian.com/jira/REST/cloud/#api/2/dashboard
Client:
this.getAllDashboards = function (opts, callback) {
var options = {
uri: this.jiraClient.buildURL('/dashboard'),
method: 'GET',
json: true,
followAllRedirects: true,
qs: {
filter: opts.filter, //
startAt: opts.startAt, // you have to pass in obj, even with null values
maxResults: opts.maxResults //
}
};
return this.jiraClient.makeRequest(options, callback);
};
It would actually rather useful to check if options are provided and maybe fallback to some default values if they are required.
I am running some update script for a large number of issues in JIRA, so while proceeding it gives read ECONNRESET error for few entries. How to solve this? is there any option there to enable the keepAlive mode?
Hi,
Trying to transition an issue to be resolved as invalid.
This is my testcode where issue is the issue key:
ID 5 is "Resolve"
function resolve_invalid(issue) {
jira.issue.transitionIssue({
issueKey: issue,
transition: {id: '5'},
fields: {resolution: {name: 'Invalid'}}
}, function (error, data) {
console.log(error);
console.log(data);
});
}
Error without the fields is 'Missing 'transition' identifier'
According to the Jira REST API, the fields object is supported.
Example:
{
"update": {
"comment": [
{
"add": {
"body": "Bug has been fixed."
}
}
]
},
"fields": {
"assignee": {
"name": "bob"
},
"resolution": {
"name": "Fixed"
}
},
"transition": {
"id": "5"
},
"historyMetadata": {
"type": "myplugin:type",
"description": "text description",
"descriptionKey": "plugin.changereason.i18.key",
"activityDescription": "text description",
"activityDescriptionKey": "plugin.activity.i18.key",
"actor": {
"id": "tony",
"displayName": "Tony",
"type": "mysystem-user",
"avatarUrl": "http://mysystem/avatar/tony.jpg",
"url": "http://mysystem/users/tony"
},
"generator": {
"id": "mysystem-1",
"type": "mysystem-application"
},
"cause": {
"id": "myevent",
"type": "mysystem-event"
},
"extraData": {
"keyvalue": "extra data",
"goes": "here"
}
}
}
Stacktrace:
TypeError: opts.fields.forEach is not a function
at IssueClient.buildRequestOptions (c:\Users\muste\WebstormProjects\arise\node_modules\jira-connector\api\issue.js:981:25)
at IssueClient.transitionIssue (c:\Users\muste\WebstormProjects\arise\node_modules\jira-connector\api\issue.js:580:28)
I npm unstalled this library and I noticed that the version on GitHub doesn't seem to match what npm provides even though the versions are the same.
From NPM:
...
"author": {
"name": "Caleb Brinkman",
"email": "[email protected]"
},
"bugs": {
"url": "https://github.com/floralvikings/jira-connector/issues"
},
"bundleDependencies": false,
"dependencies": {
"oauth": "^0.9.12",
"request": "^2.51.0"
},
"deprecated": false,
"description": "Easy to use NodeJS wrapper for the Jira REST API.",
"homepage": "https://github.com/floralvikings/jira-connector#readme",
"keywords": [
"JIRA",
"REST",
"OAuth"
],
"license": "MIT",
"main": ".",
"name": "jira-connector",
"repository": {
"type": "git",
"url": "git+ssh://[email protected]/floralvikings/jira-connector.git"
},
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "2.6.0"
Hi,
I have a search that uses expand="changelog"
. I'm porting some code from a Python script, where it so happens that the search
API abstraction chooses to use a GET request. In jira-connector
, the search.search()
method uses POST.
I think JIRA allows both and treats them more or less equally, but with POST, trying two different JIRA instances with very different data, I get a server-side error back. This may be a bug in the JIRA REST API, I'm not sure.
The error is: Can not deserialize instance of java.util.ArrayList out of VALUE_STRING token
So, small request: can we allow the method to be specified in the options passed to search()
?
I tried very quickly to hack the code to use method: 'GET'
, but I don't think the parameters are actually marshalled to the query string so that returned a lot of issues! :)
Martin
Some options use ID and some use Id
e.g.
* @method getWorkLog
* @memberOf IssueClient#
* @param {Object} opts The options to pass to the API. Note that this object must contain EITHER an issueID or
* issueKey property; issueID will be used over issueKey if both are present.
* @param {string} [opts.issueID] The ID of the issue. EX: 10002
* @param {string} [opts.issueKey] The Key of the issue. EX: JWR-3
* @param {string} opts.worklogId The id of the work log to retrieve.
issueID vs worklogId
Hello,
jira-connector depends on fs and it seems that package is no longer available.
see npm message
ERROR in ./
/jira-connector/api/issue.js/jira-connector/api/issue.js 4:9-22
Module not found: Error: Cannot resolve module 'fs' in
Portal.Client\node_modules\jira-connector\api
@ ./
Right now I am getting only single issue using this,
jira.issue.getIssue({
issueKey: 'JWR-19'
}, function(error, issue) {
console.log(issue.fields.summary);
});
How can I get multiple Issues list ?
Thanks in advance.
Great library :)
I think it would be great to migrate to request-promise: https://www.npmjs.com/package/request-promise
Who doesn't <3 promises?
I've been trying to create a version but I can't get anything but undefined
not sure why I'm missing, this is my code:
var JiraClient = require('jira-connector');
var config = require('config');
// Create jira client
const jira = new JiraClient({
host: config.get('JiraConfig.host'),
basic_auth: {
username: config.get('JiraConfig.username'),
password: config.get('JiraConfig.password')
}
});
jira.version.createVersion({
description: "An excellent version",
name: "New Version 1",
userReleaseDate: "5/Jul/2010",
project: "SQA",
archived: false,
released: true,
projectId: 10000
}, function(error, version) {
if( null !== version ) {
console.log("version created", version);
} else {
console.log(error);
}
});
Hi, I'm getting the following error on every API call:
(This is when running console.log(err); )
I'm connecting to Jira v6.4.1 using basic authentication.
When already logged in the browser, I can get to the API to give me data in the browser with both the IP and the host name of the Jira server.
When logged out I get {"errorMessages":["No project could be found with key 'PROJ'."],"errors":{}} where 'PROJ' would be the project key. This part makes sense as I am not logged in. However, this is not returned to my application when I make the API calls using jira-connector (at least not visibly to me).
Also, I can connect just fine with curl using the first command outlined here: https://developer.atlassian.com/jiradev/api-reference/jira-rest-apis/jira-rest-api-tutorials/jira-rest-api-example-basic-authentication
Any help with this issue would be greatly appreciated.
Hi! have been working with jira-connector for 2 months now. It always give error while on company network. I have a proxy for the network and I don't know how to use it with this package.
jira.search.search({
project:'My Project',
labels: 'My Label'
}, function(error, issue) {
//console.log(JSON.stringify(issue, null, 2));
});
has been returning all issues at my host. The body object appears to be empty when I console.log(options) inside of search.js.
I am trying to transition issue to done state using below code
jira.status.getAllStatuses({
issueKey: task.ticket
}, function(err, statuses) {
var doneStatus = (statuses.filter(function(status) {
return status.name === 'Done';
}))[0];
jira.issue.transitionIssue({
issueKey: task.ticket,
transition: { id: doneStatus.statusCategory.id }
}, function() {
console.log(arguments);
});
});
But this does not seem to be working. Any example would be very helpful.
Thanks in Advance.
I am trying to write a basic jira system , and need to have the appropriate user information logged in jira - so this obviously means that I have to pass the appropriate auth to each request
After looking at the code, it seems to me that I have to have a jira instance for each potential user.
I had hoped to pass in a jar
property on the option to each method call, but I can see that in a lot of places, the makebuildrequest
is not used and the function builds it's own options object to pass to makeRequest
So, the ways I see to implement my requirement are these
#1 have a jira client for each user (ok for small amount of users, potentially troublesome for a large number of users)
#2 modify all methods to use a jar
parameter if supplied
#3 add a pre-request hook so that the request can be modified before being sent to jira
to me, #3 is the most practical and easiest to implement . Any other comments ?
There is an error in your api/issue.js line 1099.
I'm trying to use https://docs.atlassian.com/jira/REST/server/#api/2/issue-doTransition and assign a new person to the issue while I transicion it.
According to the doc I have to send the fields like this:
params.fields = { assignee:{ name: person } }
params.fields.forEach is not a function in that case though.
Hey FloralVikings - thx for making this library... speed things up quite a bit for my project.
Quick typo I noticed at http://floralvikings.github.io/jira-connector/IssueClient.html - getTransition is defined twice, but the appropriate API function is transitionIssue.
Hi,
I can not get the library to connect via https:
var JiraClient = require('./index.js');
var jira = new JiraClient({
host: 'jira.foo.bar',
oauth: {
consumer_key: '...',
token: '...',
token_secret: '...',
private_key: '-----BEGIN RSA PRIVATE KEY-----\n' +
'...\n' +
'-----END RSA PRIVATE KEY-----'
}
});
jira.issue.getIssue({
issueKey: 'T-1'
}, function(error, issue) {
console.log(issue.fields.summary);
});
When I run it:
$ node test.js
TypeError: Cannot read property 'fields' of undefined
at /home/hubot/node_modules/hubot-jira-connector/node_modules/jira-connector/test.js:30:22
at Request._callback (/home/hubot/node_modules/hubot-jira-connector/node_modules/jira-connector/index.js:260:24)
at Request.self.callback (/home/hubot/node_modules/hubot-jira-connector/node_modules/jira-connector/node_modules/request/request.js:199:22)
at Request.emit (events.js:98:17)
at Request.<anonymous> (/home/hubot/node_modules/hubot-jira-connector/node_modules/jira-connector/node_modules/request/request.js:1036:10)
at Request.emit (events.js:117:20)
at IncomingMessage.<anonymous> (/home/hubot/node_modules/hubot-jira-connector/node_modules/jira-connector/node_modules/request/request.js:963:12)
at IncomingMessage.emit (events.js:117:20)
at _stream_readable.js:944:16
at process._tickCallback (node.js:448:13)
however, when I use http it works fine:
var JiraClient = require('./index.js');
var jira = new JiraClient({
host: 'jira.foo.bar',
protocol: 'http',
oauth: {
consumer_key: '...',
token: '...',
token_secret: '...',
private_key: '-----BEGIN RSA PRIVATE KEY-----\n' +
'...\n' +
'-----END RSA PRIVATE KEY-----'
}
});
jira.issue.getIssue({
issueKey: 'T-1'
}, function(error, issue) {
console.log(issue.fields.summary);
});
$ node test.js
Test ticket
Curl doesn't show any certificate errors:
$ curl -v https://jira.foo.bar/rest/api/2/issue/T-1
* Trying 54.x.x.x...
* Connected to jira.foo.bar (54.x.x.x) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
* Server certificate:
* subject: CN=*.foo.bar,O="Amazon.com, Inc.",L=Seattle,ST=Washington,C=US
* start date: Sep 14 00:00:00 2015 GMT
* expire date: Nov 04 23:59:59 2016 GMT
* common name: *.foo.bar
* issuer: CN=Symantec Class 3 Secure Server CA - G4,OU=Symantec Trust Network,O=Symantec Corporation,C=US
> GET /rest/api/2/issue/T-1 HTTP/1.1
> User-Agent: curl/7.40.0
> Host: jira.foo.bar
> Accept: */*
>
< HTTP/1.1 401 Unauthorized
< Server: nginx/1.8.1
< Date: Wed, 09 Mar 2016 08:12:09 GMT
< Content-Type: application/json;charset=UTF-8
< Transfer-Encoding: chunked
< Connection: keep-alive
< X-AREQUESTID: 492x2054338x1
< X-ASEN: SEN-4281670
< Set-Cookie: atlassian.xsrf.token=BLTD-G3C4-QIZQ-HKFG|9fd33f69c1caaecece6f5fe3f40dfca53b30daec|lout; Path=/
< X-AUSERNAME: anonymous
< Cache-Control: no-cache, no-store, no-transform
< X-Content-Type-Options: nosniff
< WWW-Authenticate: OAuth realm="http%3A%2F%2Fjira.foo.bar"
<
* Connection #0 to host jira.foo.bar left intact
{"errorMessages":["You do not have the permission to see the specified issue.","Login Required"],"errors":{}}
Any ideas what's happening here ?
I didn't find the api to get the list of status which are in current status,
Like i wana get all the status which are in In Progress?
JIRA API has an endpoint https://developer.atlassian.com/cloud/jira/software/rest/#api-board-boardId-sprint-sprintId-issue-get
for retrieving issues based on board id and sprint id. Retrieving issues just based on sprint id causes all issues to be returned. The board may be filtering issues out so there may be issues returned that should not be.
It uses the same parameters as api/sprint.js/getSprintIssues does. The only difference is that the url needs to be this.jiraClient.buildAgileURL('/board/' + opts.boardId + '/sprint/' + opts.sprintId + '/issue')
Hi,
My jira url is http://ip:8080 I can not get the connect to jira use this library,when connecting,it always use port 443 ,i cant change it.
let jira = new JiraClient({
host: '192.168.1.111',
port: '8080',
basic_auth: {
username: process.env.HUBOT_JIRA_USER,
password: process.env.HUBOT_JIRA_PASS
}
});
when i run it
ERROR!
{ Error: connect ECONNREFUSED 192.168.1.111:443
at Object.exports._errnoException (util.js:1008:11)
at exports._exceptionWithHostPort (util.js:1031:20)
at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1080:14)
code: 'ECONNREFUSED',
errno: 'ECONNREFUSED',
syscall: 'connect',
address: '192.168.1.111',
port: 443 }
please help.
It doesn't look like there's a way to download an issue's attachments.
I can call jira.issue.getIssue()
to get the attachment list, and then read the URL from response.fields.attachment[x].content
. But I couldn't find a way to download the file from that URL (with the necessary authentication headers), or preferably, pipe it to a writable stream.
The flow as described in the documentation is working fine till JiraClient.oauth_util.swapRequestTokenWithAccessToken
method call. I get the access token but creating the JiraClient
instance with consumer_key, private_key, token and token_secret in the 4th step gives oauth_problem=token_rejected error when making a API call.
Alternatively I tried to use the access_token return by JiraClient.oauth_util.getAuthorizeURL
method call to make the API request like http://<API_path>/?access_token=<access_token> this works fine.
Can anyone help me to clarify this issues.
Per the Jira api docs,
addComment can have the following payload:
"body": "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque eget venenatis elit. Duis eu justo eget augue iaculis fermentum. Sed semper quam laoreet nisi egestas at posuere augue semper.",
"visibility": {
"type": "role",
"value": "Administrators"
}
PR #25 prevents the visibility from being sent by only sending the body string. Your documentation also expects it to be an object, not a string.
Please revert #25 to its previous state.
We tried this for our jira instance :
var JiraClient = require('./node_modules/jira-connector/index.js');
JiraClient.oauth_util.getAuthorizeURL({
host: 'ourjirahost.com',
oauth: {
consumer_key: 'requiredconsumerkey',
private_key: '-----BEGIN RSA PRIVATE KEY-----\n' +
'privatekey\n'
'-----END RSA PRIVATE KEY-----'
}
}, function (error, oauth) {
console.log(oauth);
});
With all the steps provided in the doc of this addon , but it gives 'undefined' in the output when we run node .js. I am exepcting to see a json like this :
{
url: 'https://jenjinstudios.atlassian.net/plugins/servlet/oauth/authorize?oauth_token=some-token-here',
token: 'some-token-here',
token_secret: 'some-secret-here'
}
Please revert back soon as to what might be the cause of this. Also is there a way to capture that output in some variable?
The deleteSubtasks parameters should be 'deleteSubtasks' and not 'deleteSubTasks'. This causes the deleteIssue call to error out in the case that a JIRA issue has subtasks.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.