Giter Club home page Giter Club logo

lp-to-jira's Introduction

lp-to-jira

Python helper script that create a new JIRA bug entry from an existing Launchpad bug ID.

Launchpad

lp-to-jira will access Launchpad as an anonymous user for now so private bug might not be visible.

JIRA

A JIRA account is required You will need to setup a JIRA token to access your server.

On the first launch lp-to-jira will assist you in getting your jira API token. JIRA API token can be created here: https://id.atlassian.com/manage-profile/security/api-tokens.

Usage:

usage: lp-to-jira [-h] [-l LABEL] [-c COMPONENT] [-E EPIC] [-e] [-s SYNC_PROJECT_BUGS] [-d DAYS] [-t TAGS] [--add-link-in-lp-desc ] [--no-lp-tag] [bug] project

A script create JIRA issue from Launchpad bugs

positional arguments:
  bug                   The Launchpad numeric bug ID
  project               The JIRA project string key

optional arguments:
  -h, --help            show this help message and exit
  -l LABEL, --label LABEL
                        Add LABEL to the JIRA issue after creation
  -c COMPONENT, --component COMPONENT
                        Specify COMPONENT to assign the issue to
  -E EPIC, --epic EPIC  Specify EPIC to link this new issue to
  -e, --exists
                        Look if the Launchpad Bug has already been imported
                        print the JIRA issue ID if found
  -s SYNC_PROJECT_BUGS, --sync_project_bugs SYNC_PROJECT_BUGS

                        Adds all bugs from a specified LP Project to specified Jira board
                        if they are not already on the Jira board.
                        Use --days to narrow down bugs
  -d DAYS, --days DAYS  Only look for LP Bugs in the past n days
  -t TAGS, --tag TAGS
                        Only look for LP Bugs with the specified tag(s). To exclude,
                        prepend a '-', e.g. '-unwantedtag'
  --no-lp-tag           Do not add tag to LP Bug
  --add-link-in-lp-desc
                        Add JIRA link in LP Bug description

Examples:
    lp-to-jira 3215487 FR
    lp-to-jira -e 3215487 FR
    lp-to-jira -l ubuntu-meeting 3215487 PR
    lp-to-jira -s ubuntu -d 3 IQA
    lp-to-jira --no-lp-tag -c Network -E FS-543 123231 PR
    lp-to-jira -s ubuntu -t go-to-jira PR
    lp-to-jira -s ubuntu -t go-to-jira -t also-to-jira PR
    lp-to-jira -s ubuntu -t=-ignore-these PR

lp-to-jira-report

Python helper script that produces report listing all the bugs in a given project that have been imported with lp-to-jira.

(issues that have LP #1234567 in their titles)
This report will show JIRA status for the issues and LP status for the related LP bugs in all impacted series.

Usage:

usage: lp-to-jira-report [options] project-id

Report the status of all active LaunchPad bug imported
into a JIRA project with lp-to-jira

options:
    --csv FILE
        export the results of the report into FILE in csv format
    --html FILE
        export the results of the report into FILE in html format
    --json FILE
        export the results of the report into FILE in json format
    default:
        display the report on stdout

Examples:
    lp-to-jira-report FR
    lp-to-jira-report --csv  results.csv  FR
    lp-to-jira-report --json results.json FR
    lp-to-jira-report --html results.html FR

Sync while getting a report

usage: lp-to-jira-report [options] --sync project-id

This will perform the same as lp-to-jira-report except that will also sync some data from Launchpad back into your JIRA issues.

  • Title Sync: If the Launchpad Item title changed, the JIRA issues summary will be updated.
  • Release Status: If all the series impacted in Launchpad are Fix Released, the JIRA issue will automatically be moved to DONE.
  • It is possible to disable automation on the JIRA issue by creating a Label called DisableLPSync.

lp-to-jira's People

Contributors

cpaelzer avatar hkhonming avatar jocave avatar mclemenceau avatar ogayot avatar sparkiegeek avatar utkarsh2102 avatar vorlonofportland avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

lp-to-jira's Issues

Import fails 'text: Component name 'Package Management' is not valid'

installed: 0.7 (49) 10MB -

$ lp-to-jira 1966589 DT

Traceback (most recent call last):
  File "/snap/lp-to-jira/49/bin/lp-to-jira", line 8, in <module>
    sys.exit(main())
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 318, in main
    lp_to_jira_bug(lp, jira, bug, project_id, opts)
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 183, in lp_to_jira_bug
    jira_issue = create_jira_issue(jira, issue_dict, bug, opts)
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 154, in create_jira_issue
    new_issue = jira.create_issue(fields=issue_dict)
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/jira/client.py", line 1315, in create_issue
    r = self._session.post(url, data=json.dumps(data))
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/jira/resilientsession.py", line 175, in post
    return self.__verb("POST", url, **kwargs)
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/jira/resilientsession.py", line 168, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/snap/lp-to-jira/49/lib/python3.8/site-packages/jira/resilientsession.py", line 53, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://warthogs.atlassian.net/rest/api/2/issue
	text: Component name 'Package Management' is not valid
	
	response headers = {'Server': 'AtlassianProxy/1.19.3.1', 'cache-control': 'no-cache, no-store, no-transform', 'Content-Type': 'application/json;charset=UTF-8', 'Strict-Transport-Security': 'max-age=315360000; includeSubDomains; preload', 'Date': 'Thu, 07 Apr 2022 15:15:33 GMT', 'ATL-TraceId': '035cfd6eefd42414', 'x-arequestid': 'f9ef7224-0afa-4a71-aa26-e16fc3882158', 'x-aaccountid': '5f646811a1048d0069050682', 'X-XSS-Protection': '1; mode=block', 'Transfer-Encoding': 'chunked', 'timing-allow-origin': '*', 'x-envoy-upstream-service-time': '172', 'X-Content-Type-Options': 'nosniff', 'Connection': 'close', 'Expect-CT': 'report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400'}
	response text = {"errorMessages":[],"errors":{"components":"Component name 'Package Management' is not valid"}}

TypeError: __init__() should return None, not 'int' when no JIRA credentials given

$ lp-to-jira 3215487 FR
The authorization page:
 (https://launchpad.net/+authorize-token?oauth_token=<redacted>&allow_permission=DESKTOP_INTEGRATION)
should be opening in your browser. Use your browser to authorize
this program to access Launchpad on your behalf.
Waiting to hear from Launchpad about your decision...
JIRA Token information file /home/acollard/snap/lp-to-jira/common/.jira.token could not be found or parsed.

Do you want to enter your JIRA token information now? (Y/n) n
Traceback (most recent call last):
  File "/snap/lp-to-jira/13/bin/lp-to-jira", line 8, in <module>
    sys.exit(main())
  File "/snap/lp-to-jira/13/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 251, in main
    api = jira_api()
TypeError: __init__() should return None, not 'int'

trying to link lp bug to an Epic fails with "Public API does not support this request"

Ran into this while trying to convert an LP bug to a Jira issue and linking it to an Epic on a company-managed project.

bladernr@galactica:~/development/$ lp-to-jira -E MYPROJECT-160 -l 22.04 1873936 MYPROJECT
Exception ignored in: <function Magic.del at 0x7fd0ff272ca0>
Traceback (most recent call last):
File "/usr/lib/python3/dist-packages/magic/init.py", line 125, in del
if self.cookie and magic_close:
AttributeError: 'Magic' object has no attribute 'cookie'
Created https://jira-service-url/browse/MYPROJECT-197
Traceback (most recent call last):
File "/usr/local/bin/lp-to-jira", line 11, in
load_entry_point('LpToJira==0.7', 'console_scripts', 'lp-to-jira')()
File "/usr/local/lib/python3.8/dist-packages/LpToJira-0.7-py3.8.egg/LpToJira/lp_to_jira.py", line 318, in main
File "/usr/local/lib/python3.8/dist-packages/LpToJira-0.7-py3.8.egg/LpToJira/lp_to_jira.py", line 183, in lp_to_jira_bug
File "/usr/local/lib/python3.8/dist-packages/LpToJira-0.7-py3.8.egg/LpToJira/lp_to_jira.py", line 164, in create_jira_issue
File "/usr/local/lib/python3.8/dist-packages/jira-3.1.1-py3.8.egg/jira/client.py", line 4768, in add_issues_to_epic
raise NotImplementedError(
NotImplementedError: Jira Agile Public API does not support this request

allow for a list of labels

It would be helpful to be able to add more than one label to an issue when created via lp-to-jira.

For example:

lp-to-jira -l lablel1,label2,label3 BUGNUM PROJECT

What I was able to quickly find in-between meetings seems to indicate that labels in the Jira API are a list in the dict of issue properties:
https://community.atlassian.com/t5/Jira-questions/How-to-add-labels-to-Jira-via-Rest-API/qaq-p/996495
http://rest-examples.chilkat.io/jira_-_issues/python/chilkat_168.cshtml

Admittedly, I very quickly mucked with this

@@ -178,7 +178,7 @@ def lp_to_jira_bug(lp, jira, bug, project_id, opts):
     issue_dict = build_jira_issue(lp, bug, project_id, opts)
     if opts.label:
         # Add labels if specified
-        issue_dict["labels"] = [opts.label]
+        issue_dict["labels"] = opts.label.split(',')

but my test build didn't actually split the comma delimited list, but rather created a single label that looked like
label1,label2.

Maybe I'm missing something obvious and basic or misread the info on the Jira API linked above? But you already convert the text for --label into a single item list, so I'm confused why creating a multiple item list isn't working.

Pull package names regardless of whether it's Ubuntu

Currently, lp-to-jira only grabs the bug package name if the task contains Ubuntu in it, and returns None otherwise.

Many of us work on bugs that are filed against packages that may not necessarily be in Ubuntu (or may not have an Ubuntu task).

lp-to-jira just return the package name regardless and maybe what it should do is this:

If there's a task with Ubuntu in it, then return this:
[UBUNTU/package_name]

otherwise this:

[package_name]

Feature request: sync project bugs with label

It would be very handy for some of our projects if we could narrow down the bugs taken from the LP project by some tag in combination with the -s argument for example:

lp-to-jira -s ubuntu -t go-to-jira IQA

Does this sound possible?

Don't pull closed bugs (unless requested)

When running lp-to-jira to sync a project into Jira, it grabs every known bug. That can be a very expensive process if a project has hundreds or thousands of closed, historic bugs.

By default, lp-to-jira should only pull bugs that are in an open state (e.g. not in fix-release, fix-committed, invalid, wont-fix states).

For those who do want to actually sync an entire projects bug history, perhaps a --all-bugs option could be added to override this.

JiraError HTTP 400 url: https://warthogs.atlassian.net/rest/api/2/issue text: Could not find valid 'id' or 'name' in component object.

$ lp-to-jira 1842320 FR
Traceback (most recent call last):
  File "/snap/lp-to-jira/54/bin/lp-to-jira", line 8, in <module>
    sys.exit(main())
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 344, in main
    lp_to_jira_bug(lp, jira, bug, project_id, opts)
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 185, in lp_to_jira_bug
    jira_issue = create_jira_issue(jira, issue_dict, bug, opts)
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/LpToJira/lp_to_jira.py", line 156, in create_jira_issue
    new_issue = jira.create_issue(fields=issue_dict)
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/jira/client.py", line 1315, in create_issue
    r = self._session.post(url, data=json.dumps(data))
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/jira/resilientsession.py", line 175, in post
    return self.__verb("POST", url, **kwargs)
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/jira/resilientsession.py", line 168, in __verb
    raise_on_error(response, verb=verb, **kwargs)
  File "/snap/lp-to-jira/54/lib/python3.8/site-packages/jira/resilientsession.py", line 53, in raise_on_error
    raise JIRAError(
jira.exceptions.JIRAError: JiraError HTTP 400 url: https://warthogs.atlassian.net/rest/api/2/issue
        text: Could not find valid 'id' or 'name' in component object.

        response headers = {'Date': 'Tue, 18 Oct 2022 14:07:18 GMT', 'Content-Type': 'application/json;charset=UTF-8', 'Server': 'globaledge-envoy', 'Timing-Allow-Origin': '*', 'X-Arequestid': '23710c1659958551f5ed01e8468d9046', 'X-Aaccountid': '5f3cf15fd0884f0049aa8c47', 'Cache-Control': 'no-cache, no-store, no-transform', 'X-Envoy-Upstream-Service-Time': '518', 'Expect-Ct': 'report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", max-age=86400', 'Strict-Transport-Security': 'max-age=63072000; preload', 'X-Content-Type-Options': 'nosniff', 'X-Xss-Protection': '1; mode=block', 'Atl-Traceid': 'a926aec93a2189af', 'Report-To': '{"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}', 'Nel': '{"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}', 'Transfer-Encoding': 'chunked'}
        response text = {"errorMessages":[],"errors":{"components":"Could not find valid 'id' or 'name' in component object."}}

lp-to-jira report not functioning

We are using this tool to add LP bugs into our Jira project to help us manage bugs that affect our users and it's working well to import the issues.
We would like to be able to use it to automatically update our issues, or at least pull the status for all the issues we've added, which seems like 'lp-to-jira-report' would do -0 but I am getting a 'command not found' error when I try to run that command. I can pull bugs in from LP before and after running the command so I don't think it's an API issue.
Let me know if you have any suggestions!

Report does not show bug status for bugs that don't have

https://bugs.launchpad.net/plainbox-provider-certification-server/+bug/1662693
SERVCERT-326 | LP#1662693 [None] precheck script crashes if non-USB removab | Backlog | 1662693 | 6 | | none | | | | | | |

In the above bug, which was pulled in when I did a project sync, lp-to-jira-report is not showing the bug status. The bug is marked Fix Released for the package, but I suspect that it's just recognizing those statuses from Release tasks, and doesn't account for things that don't have Release tasks assigned.

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.