sync_current_sprint.py 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. import requests
  2. import urllib3
  3. from datetime import datetime
  4. urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
  5. base_url = 'https://192.168.130.161/taiga/api/v1'
  6. def sync():
  7. try:
  8. # Authenticate
  9. auth = requests.post(f'{base_url}/auth', json={'type': 'normal', 'username': 'FrancoisLange', 'password': 'BTSai123'}, verify=False).json()
  10. headers = {'Authorization': f'Bearer {auth["auth_token"]}', 'Content-Type': 'application/json'}
  11. proj_id = 21
  12. # 1. Fetch Milestones
  13. milestones = requests.get(f'{base_url}/milestones?project={proj_id}', headers=headers, verify=False).json()
  14. # We will create Sprint 9 if it doesn't exist
  15. sprint9 = next((m for m in milestones if m['name'] == 'Sprint 9'), None)
  16. if not sprint9:
  17. sprint_start = datetime.now()
  18. payload = {
  19. "project": proj_id,
  20. "name": "Sprint 9",
  21. "estimated_start": sprint_start.strftime('%Y-%m-%d'),
  22. "estimated_finish": sprint_start.strftime('%Y-%m-%d')
  23. }
  24. sprint9 = requests.post(f'{base_url}/milestones', json=payload, headers=headers, verify=False).json()
  25. print("Created Sprint 9")
  26. sprint_id = sprint9['id']
  27. # 2. Create User Story
  28. us_payload = {
  29. "project": proj_id,
  30. "subject": "Deep Containerization and Zabbix Telemetry Overhaul",
  31. "description": "Split the monolith into isolated Docker containers (App, MySQL, Ollama, Ingest) and configure Zabbix trigger dependencies (App Failure depends on DB Failure).",
  32. "milestone": sprint_id
  33. }
  34. res = requests.post(f'{base_url}/userstories', json=us_payload, headers=headers, verify=False).json()
  35. us_id = res['id']
  36. print(f"Created US: TG-{res['ref']}")
  37. # 3. Create Tasks
  38. tasks = [
  39. "Centralize docker-compose.yml with individual component services",
  40. "Integrate NVIDIA GPU support for Ollama container",
  41. "Update App and Ingest Dockerfiles to include SNMP telemetry packages",
  42. "Write Zabbix API script to create App -> MySQL trigger dependencies",
  43. "Sync Git repository and update Taiga tracking"
  44. ]
  45. for task_subject in tasks:
  46. t_payload = {"project": proj_id, "subject": task_subject, "user_story": us_id, "milestone": sprint_id}
  47. t_res = requests.post(f'{base_url}/tasks', json=t_payload, headers=headers, verify=False).json()
  48. print(f"Created Task: TG-{t_res['ref']}")
  49. print("Successfully synchronized with Taiga.")
  50. except Exception as e:
  51. print(f"Error syncing to Taiga: {e}")
  52. if __name__ == "__main__":
  53. sync()