plane icon indicating copy to clipboard operation
plane copied to clipboard

[bug]: Jira Importer non functional on Self Hosted

Open Doldge opened this issue 1 year ago • 11 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

When I import a project from Jira on my self-hosted instance of plane, running v0.13.2, I expect the Jira Epics & "stories" to import into my plane project.

However, this does not happen.

Steps to reproduce

  1. Go to Workspace Settings -> Imports
  2. Select "Import" from Jira
  3. fill in the apropriate details
  4. edit the jira_project_issue_summary python function and change the issue_url to import issuetype=Task instead of issuetype=Story
    1. if this step isn't taken then the import fails on 'Story' not being valid
  5. run through the rest of the import steps
  6. tail the worker [celery] docker logs to confirm that plane.bgtasks.importer_task.service_importer is started
  7. confirm that plane.bgtasks.importer_task.service_importer finishes
  8. check the existing project you imported the issues into
  9. the project does not have any issues or epics created.

Browser

Mozilla Firefox

Version

Self-hosted v0.13.2

Doldge avatar Dec 19 '23 02:12 Doldge

additional notes:

  • The rests of the import steps present correctly and state that XX number of issues are going to be imported.

  • The Import gets set to "Processing" but never gets set to "Completed"

  • I grepped around the code base but couldn't find any code that looked like it actually did the issue import.

    • Does this code actually exist? and if so where?
    • was expecting to see something related to the imported_data column of importers but AFAICT nothing is setting data in that column
    • the data in importers.data only appears to have a summary of the issue & epic numbers but not the actual issue & epic data.
  • There's no documentation on what to expect from the importer so it's not clear if I should even expect it to import issues.

    • If the importer doesn't import issues, why does it present a summary of the number of issues to import?

    This is a follow on from #451

Doldge avatar Dec 19 '23 02:12 Doldge

facing the same issue. please help. i successfully imported it in my cloud instance but cant in self hosted. also emails arent being sent.

Gauravoid avatar Dec 22 '23 03:12 Gauravoid

@Doldge, @Gauravoid, currently, integrations and importers are only available on the cloud version. This is because we utilize a separate server for communication with other services. For self-hosted versions, we aim to spare our users from managing additional servers for integrations and importers. Therefore, we are developing an architecture that simplifies the process for users, eliminating the need to set up multiple servers. This development has already begun (see https://github.com/makeplane/plane/pull/3248 and https://github.com/makeplane/plane/tree/feat/segway-implementation), and we plan to include it in the next few releases.

In the meantime, if you could provide details on use cases or additional context, such as:

  • The number of projects being migrated
  • The estimated total number of issues being migrated
  • User migration details (either through authorization automation or manual assignment) etc.

Answers to these questions will help us enhance your experience.

vihar avatar Dec 27 '23 18:12 vihar

Hi @vihar

thanks for getting back to me.

In my specific instance, I've only got a single Jira Project that I'm looking to migrate. The project summary is:

  • 161 issues
  • 4 states
  • 26 modules
  • 14 users
  • 0 labels

As far as user migration goes, I'm happy to just manually sort that after the project is migrated.

Doldge avatar Dec 28 '23 01:12 Doldge

Hello @Doldge,

Here is the code that I come up with: jira.py.zip I also uploaded the file in zip as the following formatting is not the best, but anyway, the code is here to be checked as well: ` import requests from requests.auth import HTTPBasicAuth from sentry_sdk import capture_exception

def jira_project_issue_summary(email, api_token, project_key, hostname): try: auth = HTTPBasicAuth(email, api_token) headers = {"Accept": "application/json"}

    # Check API version for Jira.
    test_url_v3 = f"https://{hostname}/rest/api/3/project/{project_key}"
    test_url_v2 = f"https://{hostname}/rest/api/2/project/{project_key}"

    # Try API v3 if not valid than use API v2
    response = requests.get(test_url_v3, headers=headers, auth=auth)
    if response.status_code == 200:
        api_ver = "3"
    else:
        api_ver = "2"

    issue_url = f"https://{hostname}/rest/api/{api_ver}/search?jql=project={project_key} AND issuetype=Story"
    issue_response = requests.request(
        "GET", issue_url, headers=headers, auth=auth
    ).json()["total"]

    module_url = f"https://{hostname}/rest/api/{api_ver}/search?jql=project={project_key} AND issuetype=Epic"
    module_response = requests.request(
        "GET", module_url, headers=headers, auth=auth
    ).json()["total"]

    status_url = f"https://{hostname}/rest/api/{api_ver}/status/?jql=project={project_key}"
    status_response = requests.request(
        "GET", status_url, headers=headers, auth=auth
    ).json()

    if api_ver == "3":
        labels_url = f"https://{hostname}/rest/api/{api_ver}/label/?jql=project={project_key}"
        labels_response = requests.request(
            "GET", labels_url, headers=headers, auth=auth
        ).json()["total"]
    else:
        labels_url = f"https://{hostname}/rest/api/{api_ver}/jql/autocompletedata/suggestions?fieldName=labels"
        labels_response = requests.request(
            "GET", labels_url, headers=headers, auth=auth
        ).json()

    if api_ver == "3":
        users_url = (
            f"https://{hostname}/rest/api/{api_ver}/users/search?jql=project={project_key}"
        )
    else:
        users_url = f"https://{hostname}/rest/api/{api_ver}/user/search?username=."
    users_response = requests.request(
        "GET", users_url, headers=headers, auth=auth
    ).json()
    if api_ver == "3":
        return {
            "issues": issue_response,
            "modules": module_response,
            "labels": labels_response,
            "states": len(status_response),
            "users": (
                [
                    user
                    for user in users_response
                    if user.get("accountType") == "atlassian"
                ]
            ),
        }
    else:
        return {
            "issues": issue_response,
            "modules": module_response,
            "labels": labels_response,
            "states": len(status_response),
            "users": users_response
        }
except Exception as e:
    capture_exception(e)
    return {"error": "Something went wrong could not fetch information from jira"}

` it supports both API versions of Jira (API v3 for Cloud and API v2 for self hosted Jira Server and Data Center) but it doesn't support PAT (Personal Access Tokens) in some cases this kind of authentication is forced instead of basic authentication - This I have in plan to develop in future as no time for it at the moment.

The file that should be replaced (make a backup of it first) is located here: apiserver/plane/utils/importers/jira.py

I did test the file as it is (without using Plane) and worked on both API versions, so this is why I asked to make a backup first, before modifying it, even better - if you have a playground installation of Plane to test this out.

I hope the code will be helpful in the future development of Jira migration to Plane.

All the best and a Happy new year to everyone! George

gxgl avatar Dec 31 '23 10:12 gxgl

Hi George [ @gxgl ],

I appreciate your intention to provide some assistance with this.

Unfortunately your proposed file/change doesn't help, as the issue is that the jira_project_issue_summary function just reports a summary of what the import is intending to do [i.e. collects ['totals']], but doesn't actually do the import of the data.

I look forward to further updates from @vihar; In the mean time, let me know if there's anything I can do to help move this forward [I'm a python dev by day, so can provide assistance if needed].

Doldge avatar Jan 08 '24 23:01 Doldge

The number of projects being migrated: >200 The estimated total number of issues being migrated: ~60k

CybotTM avatar Feb 21 '24 07:02 CybotTM

Hi @vihar are there any updates on this? (I've seen that there is a segway PRs, one aimed to v0.16 was closed and other was merged into v0.15. The latter seems to be aim for cloud host though).

Not being able to import existing Jira project quite hurts an attempt to do a tryout as a self-hosted.

rredkovich avatar Mar 27 '24 13:03 rredkovich

Running v0.18-dev and can't find any importers. They're completely missing: CleanShot 2024-04-27 at 11 12 13@2x

Have they been removed? Best Regarsd.

florian-obradovic avatar Apr 27 '24 09:04 florian-obradovic

Hi @florian-obradovic as explained above in this thread, JIRA importers only worked on Cloud. We are working on getting this in self hosted deployments soon. Will update this thread.

gchanchal avatar Apr 29 '24 07:04 gchanchal

@gchanchal 😂 sorry for not reading this, stupid me.

My Datacenter Environment:

  • current jira datacenter
  • 5-10 Projects
  • 15-20k issues

My Cloud Environment:

  • 1-2 Projects
  • 300 issues

florian-obradovic avatar Apr 29 '24 16:04 florian-obradovic