#!/bin/bash # Week 1 Day 2: Create Projects via API # Using correct REST API v3 endpoint: POST /rest/api/3/project # Reference: https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-projects/ source /tmp/atlassian-setup/credentials.env echo "=== Creating Jira Projects via REST API v3 ===" echo "" # Function to create project create_project() { local key=$1 local name=$2 local project_type=$3 local template_key=$4 local description=$5 local lead_id=$6 echo "Creating project: $key - $name ($project_type)" # Correct payload based on Atlassian example local json_payload=$(cat </dev/null || echo "$body" elif [ "$http_code" = "403" ]; then echo "⚠ Forbidden (HTTP 403) - Insufficient permissions" echo "$body" | jq . 2>/dev/null || echo "$body" else echo "Response: $body" fi echo "" } echo "Template Keys Reference:" echo " scrum: com.atlassian.jira-core-project-templates:jira-scrum-project" echo " kanban: com.atlassian.jira-core-project-templates:jira-kanban-project" echo " business: com.atlassian.jira-core-project-templates:jira-core-simplified-process-control" echo " service-desk: com.atlassian.servicedesk.project-templates:it-help-desk" echo "" # Create projects # Format: key, name, projectTypeKey, projectTemplateKey, description create_project \ "PROD" \ "Product & Engineering" \ "software" \ "com.atlassian.jira-core-project-templates:jira-scrum-project" \ "Website development and client project delivery" create_project \ "MARK" \ "Marketing & Sales" \ "software" \ "com.atlassian.jira-core-project-templates:jira-kanban-project" \ "Sales pipeline, leads, clients, and marketing campaigns" create_project \ "SUPP" \ "Customer Support" \ "service_management" \ "com.atlassian.servicedesk.project-templates:it-help-desk" \ "Client tickets, technical support, and escalations" create_project \ "OPS" \ "Operations" \ "business" \ "com.atlassian.jira-core-project-templates:jira-core-simplified-process-control" \ "Finance, contracts, HR, and compliance" echo "=== Project Creation Complete ===" echo "" echo "Next steps:" echo "1. Verify projects created: /opt/00-infrastructure/atlassian/atlassian-setup.sh check" echo "2. Run phase 2 to create custom fields: ./scripts/04-create-custom-fields.sh"