-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample_import.py
More file actions
66 lines (53 loc) · 2.31 KB
/
Copy pathexample_import.py
File metadata and controls
66 lines (53 loc) · 2.31 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#!/usr/bin/env python3
"""
Example script showing how to use the JIRA to ClickUp importer.
"""
import os
from dotenv import load_dotenv
from jira_to_clickup import JiraToClickUpImporter
def example_usage():
"""Example of how to use the importer programmatically"""
# Load environment variables from .env file
load_dotenv()
# Get configuration from environment variables
API_TOKEN = os.getenv('CLICKUP_API_TOKEN')
LIST_ID = os.getenv('CLICKUP_LIST_ID')
XML_FILE = os.getenv('JIRA_XML_FILE', 'sisr-export.xml')
JIRA_BASE_URL = os.getenv('JIRA_BASE_URL')
JIRA_API_TOKEN = os.getenv('JIRA_API_TOKEN')
JIRA_EMAIL = os.getenv('JIRA_EMAIL')
# Validate required environment variables
if not API_TOKEN:
print("Error: CLICKUP_API_TOKEN environment variable is required")
print("Please set it in your .env file or environment")
return
if not LIST_ID:
print("Error: CLICKUP_LIST_ID environment variable is required")
print("Please set it in your .env file or environment")
return
# Warn about optional JIRA configuration for attachments
if not JIRA_BASE_URL or not JIRA_API_TOKEN or not JIRA_EMAIL:
print("⚠️ WARNING: JIRA_BASE_URL, JIRA_API_TOKEN, or JIRA_EMAIL not configured")
print(" Attachments will be skipped during import")
print(" Set these in your .env file to enable attachment downloads")
# Create the importer
importer = JiraToClickUpImporter(API_TOKEN, LIST_ID, JIRA_BASE_URL, JIRA_API_TOKEN, JIRA_EMAIL)
try:
# Parse the JIRA XML
print("Parsing JIRA XML...")
tasks = importer.parse_jira_xml(XML_FILE)
print(f"Found {len(tasks)} tasks to import")
# First, do a dry run to see what would be imported
print("\nDoing dry run...")
importer.import_tasks(tasks, dry_run=True)
# Ask for confirmation
response = input("\nDo you want to proceed with the actual import? (y/N): ")
if response.lower() == 'y':
print("\nStarting actual import...")
importer.import_tasks(tasks, dry_run=False)
else:
print("Import cancelled.")
except Exception as e:
print(f"Error: {e}")
if __name__ == "__main__":
example_usage()