Git Product home page Git Product logo

jira-dependency-graph's Introduction

jira-dependency-graph

Graph visualizer for dependencies between JIRA tickets. Takes into account subtasks and issue links.

Uses JIRA rest API v2 for fetching information on issues. Uses Google Chart API for graphical presentation.

Example output

Example graph

Requirements:

Or

Usage:

$ git clone https://github.com/pawelrychlik/jira-dependency-graph.git
$ virtualenv .virtualenv && source .virtualenv/bin/activate # OPTIONAL
$ cd jira-dependency-graph
$ pip install -r requirements.txt
$ python jira-dependency-graph.py --user=your-jira-username --password=your-jira-password --jira=url-of-your-jira-site issue-key

Or if you prefer running in docker:

$ git clone https://github.com/pawelrychlik/jira-dependency-graph.git
$ cd jira-dependency-graph
$ docker build -t jira .
$ docker run -v $PWD/out:/out jira python jira-dependency-graph.py --user=your-jira-username --password=your-jira-password --jira=url-of-your-jira-site --file=/out/output.png issue-key
# e.g.:
$ python jira-dependency-graph.py --user=pawelrychlik --password=s3cr3t --jira=https://your-company.jira.com JIRATICKET-718

Fetching JIRATICKET-2451
JIRATICKET-2451 <= is blocked by <= JIRATICKET-3853
JIRATICKET-2451 <= is blocked by <= JIRATICKET-3968
JIRATICKET-2451 <= is blocked by <= JIRATICKET-3126
JIRATICKET-2451 <= is blocked by <= JIRATICKET-2977
Fetching JIRATICKET-3853
JIRATICKET-3853 => blocks => JIRATICKET-2451
JIRATICKET-3853 <= relates to <= JIRATICKET-3968
Fetching JIRATICKET-3968
JIRATICKET-3968 => blocks => JIRATICKET-2451
JIRATICKET-3968 => relates to => JIRATICKET-3853
Fetching JIRATICKET-3126
JIRATICKET-3126 => blocks => JIRATICKET-2451
JIRATICKET-3126 => testing discovered => JIRATICKET-3571
Fetching JIRATICKET-3571
JIRATICKET-3571 <= discovered while testing <= JIRATICKET-3126
Fetching JIRATICKET-2977
JIRATICKET-2977 => blocks => JIRATICKET-2451

Writing to issue_graph.png

Result: Example result

Advanced Usage:

List of all configuration options with descriptions:

python jira-dependency-graph.py --help

Excluding Links

In case you have specific issue links you don't want to see in your graph, you can exclude them:

$ python jira-dependency-graph.py --user=your-jira-username --password=your-jira-password --jira=url-of-your-jira-site --exclude-link 'is required by' --exclude-link 'duplicates' issue-key

The grapher will still walk the link, just exclude the edge. This especially useful for bidirectional links and you only want to see one of them, e.g. depends on and is required by.

Excluding Epics

In case you want to exclude walking into issues of an Epic, you can ignore them:

$ python jira-dependency-graph.py --user=your-jira-username --password=your-jira-password --jira=url-of-your-jira-site --ignore-epic issue-key

Including Issues

In order to only specify issues with a certain prefix pass in --issue-include <XXX> and all tickets will be checked that they match the prefix XXX.

Excluding Issues

By passing in --issue-exclude, or -xi the system will explicitly ignore the ticket. It can be repeated multiple times, e.g. -xi MYPR-456 -x MYPR-999 to ignore both issues. Use it as a last-resort only, when other means of exclusion do not suit your case, e.g. to omit a part of the graph for better readability.

Authentication

It is possible to either use:

If you are using Atlassian Cloud, use your API token instead of your account password. You can generate one with the following steps:

  1. Access https://id.atlassian.com/manage-profile/security/api-tokens.
  2. Click "Create API token".
  3. Copy the token and store it in a safe place.

More details about API authentication is available in the official documentation.

Closed Issues

By passing in --ignore-closed the system will ignore any ticket that is closed.

Multiple Issues

Multiple issue-keys can be passed in via space separated format e.g.

$ python jira-dependency-graph.py --cookie <JSESSIONID> issue-key1 issue-key2

JQL Query

Instead of passing issue-keys, a Jira Query Language command can be passed with --jql e.g.

$ python jira-dependency-graph.py --cookie <JSESSIONID> --jql 'project = JRADEV'

Usage without Google Graphviz API:

If you have issues with the Google Graphviz API limitations you can use your local graphviz installation like this:

$ git clone https://github.com/pawelrychlik/jira-dependency-graph.git
$ cd jira-dependency-graph
$ python jira-dependency-graph.py --user=your-jira-username --password=your-jira-password --jira=url-of-your-jira-site --local issue-key | dot -Tpng > issue_graph.png

Note: Its possible that the graph produced is too wide if you have a number of issues. In this case, it is better to firstly pipe the graph to a 'dot' text file e.g.

$ python jira-dependency-graph.py --jira=url-of-your-jira-site --local issue-key > graph.dot

and then process it using unflatten:

unflatten -f -l 4 -c 16 graph.dot  | dot | gvpack -array_t6 | neato -s -n2 -Tpng -o graph.png

For a slightly cleaner layout (that preserves the ranks), or if your system doesn't have unflatten, you can use sed to insert rankdir=LR; into the dot file before processing it:

sed -i 's/digraph{/digraph{ rankdir=LR;/g' graph.dot | dot -o graph.png -Tpng

Notes:

Based on: draw-chart.py and Atlassian JIRA development documentation, which seemingly was no longer compatible with JIRA REST API Version 2.

jira-dependency-graph's People

Contributors

balain avatar blesenechal avatar brownterryn avatar dionjwa avatar fuzzyhandle avatar jbruand avatar kingchad1989 avatar lisahelm avatar mcgwiz avatar pawelrychlik avatar pbaris avatar pradzins avatar quiram avatar rnc avatar thomas0306 avatar vikstrous avatar waynr avatar whiskeysierra avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

jira-dependency-graph's Issues

"No connection adapters were found for" - getting same error in both docker method, and with installed python

$ python jira-dependency-graph.py --user=[username] --password=[password] -jira=https://[FQDN] --file=output.png  OPSTEAM-2825
Fetching OPSTEAM-2825
Traceback (most recent call last):
  File "jira-dependency-graph.py", line 281, in <module>
    main()
  File "jira-dependency-graph.py", line 272, in main
    graph = graph + build_graph_data(issue, jira, options.excludes, options.show_directions, options.directions, options.includes, options.closed, options.ignore_epic, options.ignore_subtasks, options.traverse, options.word_wrap)
  File "jira-dependency-graph.py", line 199, in build_graph_data
    return walk(start_issue_key, [])
  File "jira-dependency-graph.py", line 149, in walk
    issue = jira.get_issue(issue_key)
  File "jira-dependency-graph.py", line 51, in get_issue
    response = self.get('/issue/%s' % key, params={'fields': self.fields})
  File "jira-dependency-graph.py", line 44, in get
    return requests.get(url, params=params, auth=self.auth, headers=headers, verify=(not self.no_verify_ssl))
  File "/home/carl/dev/.virtualenv/lib/python2.7/site-packages/requests/api.py", line 72, in get
    return request('get', url, params=params, **kwargs)
  File "/home/carl/dev/.virtualenv/lib/python2.7/site-packages/requests/api.py", line 58, in request
    return session.request(method=method, url=url, **kwargs)
  File "/home/carl/dev/.virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 512, in request
    resp = self.send(prep, **send_kwargs)
  File "/home/carl/dev/.virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 616, in send
    adapter = self.get_adapter(url=request.url)
  File "/home/carl/dev/.virtualenv/lib/python2.7/site-packages/requests/sessions.py", line 707, in get_adapter
    raise InvalidSchema("No connection adapters were found for '%s'" % url)
requests.exceptions.InvalidSchema: No connection adapters were found for 'ira=https://[same FQDN]/rest/api/latest/issue/OPSTEAM-2825'

Any thoughts would be appreciated; I'm not a python dev but I do have some dev experience.

Exclude link not excluding "relates to"

jira-dependency-graph.py:
--exclude-link 'relates to' --exclude-link 'SAFe Parent of' --exclude-link 'SAFe Child of' --ignore-epic --show-directions outward --ignore-subtasks --dont-traverse --local $ISSUE > $ISSUE.dot

'SAFe Parent of' and 'SAFe Child of' work
'relates to' does not

image

Writing to issue_graph fails due to Google Charts GET params limit

Trying to get this set up for one of my Jira users, on Max and Linux this works great, putting it on windows was a bit more tricky but I got it working just, but when the API call to Google Charts occurs, the returned issue_graph.png is empty 👎 Any idea what could be going on?

Link types not to follow?

Hi,

First of all, thanks a lot for this tool, I find it very useful for managing dependencies across tickets.

I was wondering if the following functionality is possible: I know I can mark certain link types so they aren't shown in the graph using --exclude-link, but this still walks the link and grabs the related tickets, which would then appear unlinked to anything else. I need the tool not to follow the excluded link at all, is there an option for this?

Many thanks!

Change readme.md readme with Atlassian Cloud auth instructions

Working with Atlassian Cloud, We must replace password by an API token, it's not clear on readme.me.

I can submit a PR if you agree, but basically is something like:

Authentication

Are you using Atlassian Cloud? use your API token instead of your account password, you can generate one following these steps:

Here's the official doc.
https://developer.atlassian.com/cloud/jira/platform/basic-auth-for-rest-apis/

Unreadable PNG

When I try to open the generated .png file, I get the following:

Screen Shot 2020-09-10 at 2 06 35 PM

Clarify supported Jira products in README

Does jira-dependency-graph support Jira Cloud, Jira Server, or both?

I notice the API documentation linked is that for Jira Server. I would like to use jira-dependency-graph with Jira Cloud, but I got a 401 error when I tried. It would be helpful if the README made it clear which product(s) are supported.

Thanks!

Handle dependencies for epics

IDs of issues linked to a given epic are not available by simply GETting that epic via the REST API. AFAIK, first we need to run a JQL search for issues that have epicLink = "my-epic", then build the graph from all the yielded issues.

HttpError 401 when using JIRA Cloud

Hi,
as already mentioned in #30 , when using jira-dependency-graph with JIRA cloud, unfortunately an HttpError 401 is received:

Traceback (most recent call last):
  File "/jira/jira-dependency-graph.py", line 302, in <module>
    main()
  File "/jira/jira-dependency-graph.py", line 291, in main
    graph = graph + build_graph_data(issue, jira, options.excludes, options.show_directions, options.directions,
  File "/jira/jira-dependency-graph.py", line 207, in build_graph_data
    return walk(start_issue_key, [])
  File "/jira/jira-dependency-graph.py", line 157, in walk
    issue = jira.get_issue(issue_key)
  File "/jira/jira-dependency-graph.py", line 49, in get_issue
    response.raise_for_status()
  File "/usr/local/lib/python3.9/site-packages/requests/models.py", line 953, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 401 Client Error: Unauthorized for url: [..]

That's really a pity, I was so looking forward to see that dependency graph :)

Unable to get the request working

Hello:

This may be a configuration issue. May not be a bug. But I dont have a contact info. So filing the bug.
Your help is appreciated.
I installed required software and executed this command. But getting these errors
1.Do i need to set up a proxy ?
2. What is the prerequisite i should check for.
3. Should i be able to send a REST request to jira with my user id and password?

Here is my request
python jira-dependency-graph.py --user=[email protected] --password="xxxxxxx" --jira
=https://jira.oraclecorp.com OAM-25342

Fetching OAM-25342
Traceback (most recent call last):
File "jira-dependency-graph.py", line 281, in
main()
File "jira-dependency-graph.py", line 272, in main
graph = graph + build_graph_data(issue, jira, options.excludes, options.show_directions, options.directions, options.includes, options.closed, options.ignore_epic, options.ignore_subtasks, options.traverse, options.word_wrap)
File "jira-dependency-graph.py", line 199, in build_graph_data
return walk(start_issue_key, [])
File "jira-dependency-graph.py", line 149, in walk
issue = jira.get_issue(issue_key)
File "jira-dependency-graph.py", line 52, in get_issue
response.raise_for_status()
File "/usr/lib/python2.7/site-packages/requests/models.py", line 834, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found

Problem with encoding when default encoding is ascii

Hi,
Noticed when I was running this script toward our Jira instant that we had fields that could be encoded in other characters that was not always within the range of ascii.

Did test out the following addition to make sure it got formatted as UTF-8 instead, which seems to work fine:

Line 99:
if islink: return '"{}\\n({})"'.format(issue_key.encode('utf-8'), summary.encode('utf-8')) return '"{}\\n({})" [href="{}", fillcolor="{}", style=filled]'.format(issue_key.encode('utf-8'), summary.encode('utf-8'), jira.get_issue_uri(issue_key).encode('utf-8'), get_status_color(status).encode('utf-8'))**

The only addition here is the .encode ('UTF-8') to overcome the error I had before regarding Ascii enconding failure.

If you think it sounds like a good option it would be nice to include

diacritics in link name causes app crash

We have localized link names to Czech using diacritics. Then script process such link name it crashes with following:

Fetching RIO-1887
RIO-1887 => souvisí s => RIO-1897
Traceback (most recent call last): File "jira-dependency-graph.py", line 286, in <module> main() File "jira-dependency-graph.py", line 277, in main options.ignore_subtasks, options.traverse, options.word_wrap) File "jira-dependency-graph.py", line 201, in build_graph_data return walk(start_issue_key, []) File "jira-dependency-graph.py", line 197, in walk walk(child, graph) File "jira-dependency-graph.py", line 189, in walk result = process_link(fields, issue_key, other_link) File "jira-dependency-graph.py", line 142, in process_link link_type, extra) UnicodeEncodeError: 'ascii' codec can't encode character u'\xed' in position 6: ordinal not in range(128)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.