makeplane / plane

🔥 🔥 🔥 Open Source JIRA, Linear and Asana Alternative. Plane helps you track your issues, epics, and product roadmaps in the simplest way possible.
http://plane.so
GNU Affero General Public License v3.0
26.37k stars 1.45k forks source link

[bug]: Jira Importer non functional on Self Hosted #3181

Open Doldge opened 7 months ago

Doldge commented 7 months ago

Is there an existing issue for this?

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 commented 7 months ago

additional notes:

Gauravoid commented 7 months ago

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

vihar commented 7 months ago

@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:

Answers to these questions will help us enhance your experience.

Doldge commented 7 months ago

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:

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

gxgl commented 7 months ago

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

Doldge commented 6 months ago

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].

CybotTM commented 5 months ago

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

rredkovich commented 4 months ago

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.

florian-obradovic commented 3 months ago

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.

gchanchal commented 3 months ago

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.

florian-obradovic commented 3 months ago

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

My Datacenter Environment:

My Cloud Environment: