#!/bin/bash # AImpress Atlassian Setup Script # Run this in Claude Code with API access # ============================================ # CONFIGURATION # ============================================ export JIRA_EMAIL="v.samoilenko@ai-impress.com" export JIRA_TOKEN="ATATT3xFfGF0ABlJi4MORJ1Mlyb6ZhR-I984TYCrUhoGH3yHf0bjhZKkJ_pk27s6mrb-GVoVtr0bXmXWtYDyQt0QL0Ut6BNpmfrz1ATJnIbqAsWVuWeKHxqyKJ8gZVApsi8OBc-jC2BVoG9TUEBDPDMWmG_0JG3zFU6bv8jTmGecwe2xlZzTiJo=E0093140" export JIRA_AUTH=$(echo -n "${JIRA_EMAIL}:${JIRA_TOKEN}" | base64) export JIRA_URL="https://ai-impress.atlassian.net" # ============================================ # 1. CONVERT KAN TO COMPANY-MANAGED # ============================================ # Note: Cannot convert existing project. Need to: # 1. Create new Company-managed project # 2. Move issues from KAN # 3. Delete old KAN echo "=== Creating new TEAM project (Company-managed) ===" curl -s -X POST \ "${JIRA_URL}/rest/api/3/project" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "key": "TEAM", "name": "Internal Team", "description": "Internal team tasks and company roadmap", "projectTypeKey": "software", "projectTemplateKey": "com.pyxis.greenhopper.jira:gh-simplified-kanban-classic", "leadAccountId": "712020:7ea4a2d0-a562-4e28-beea-1e77538886b4", "assigneeType": "PROJECT_LEAD" }' echo "" sleep 2 # ============================================ # 2. CUSTOM FIELDS - TEXT FIELDS # ============================================ echo "=== Creating Text Custom Fields ===" # Company Name curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Company Name", "description": "Client/Lead company name", "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" }' echo "Created: Company Name" sleep 1 # Contact Email curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contact Email", "description": "Primary contact email address", "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" }' echo "Created: Contact Email" sleep 1 # Contact Phone curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contact Phone", "description": "Primary contact phone number", "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" }' echo "Created: Contact Phone" sleep 1 # Contact Name curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contact Name", "description": "Primary contact person name", "type": "com.atlassian.jira.plugin.system.customfieldtypes:textfield", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:textsearcher" }' echo "Created: Contact Name" sleep 1 # Website URL curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Website URL", "description": "Company website URL", "type": "com.atlassian.jira.plugin.system.customfieldtypes:url", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:exacttextsearcher" }' echo "Created: Website URL" sleep 1 # LinkedIn URL curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "LinkedIn URL", "description": "LinkedIn profile or company page URL", "type": "com.atlassian.jira.plugin.system.customfieldtypes:url", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:exacttextsearcher" }' echo "Created: LinkedIn URL" sleep 1 # ============================================ # 3. CUSTOM FIELDS - NUMBER FIELDS # ============================================ echo "=== Creating Number Custom Fields ===" # Deal Value curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Deal Value", "description": "Expected deal value in GBP (£)", "type": "com.atlassian.jira.plugin.system.customfieldtypes:float", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:exactnumber" }' echo "Created: Deal Value" sleep 1 # Invoice Amount curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice Amount", "description": "Invoice amount in GBP (£)", "type": "com.atlassian.jira.plugin.system.customfieldtypes:float", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:exactnumber" }' echo "Created: Invoice Amount" sleep 1 # VAT Amount curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "VAT Amount", "description": "VAT amount in GBP (£)", "type": "com.atlassian.jira.plugin.system.customfieldtypes:float", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:exactnumber" }' echo "Created: VAT Amount" sleep 1 # ============================================ # 4. CUSTOM FIELDS - DATE FIELDS # ============================================ echo "=== Creating Date Custom Fields ===" # Expected Close Date curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Expected Close Date", "description": "Expected date to close the deal", "type": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:daterange" }' echo "Created: Expected Close Date" sleep 1 # Invoice Date curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice Date", "description": "Date invoice was issued", "type": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:daterange" }' echo "Created: Invoice Date" sleep 1 # Payment Due Date curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Payment Due Date", "description": "Date payment is due", "type": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:daterange" }' echo "Created: Payment Due Date" sleep 1 # Contract Start Date curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contract Start Date", "description": "Contract start date", "type": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:daterange" }' echo "Created: Contract Start Date" sleep 1 # Contract End Date curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contract End Date", "description": "Contract end date", "type": "com.atlassian.jira.plugin.system.customfieldtypes:datepicker", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:daterange" }' echo "Created: Contract End Date" sleep 1 # ============================================ # 5. CUSTOM FIELDS - SELECT FIELDS # ============================================ echo "=== Creating Select Custom Fields ===" # Lead Source curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Lead Source", "description": "Source of the lead", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Lead Source" sleep 1 # Lead Status curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Lead Status", "description": "Current status of the lead", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Lead Status" sleep 1 # Service Package curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Service Package", "description": "AImpress service package", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Service Package" sleep 1 # Invoice Status curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Invoice Status", "description": "Current status of the invoice", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Invoice Status" sleep 1 # Contract Type curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Contract Type", "description": "Type of contract", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Contract Type" sleep 1 # Ticket Category curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Ticket Category", "description": "Support ticket category", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Ticket Category" sleep 1 # SLA Priority curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "SLA Priority", "description": "SLA priority level", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: SLA Priority" sleep 1 # Environment curl -s -X POST \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Environment", "description": "Deployment environment", "type": "com.atlassian.jira.plugin.system.customfieldtypes:select", "searcherKey": "com.atlassian.jira.plugin.system.customfieldtypes:multiselectsearcher" }' echo "Created: Environment" sleep 1 echo "" echo "=== Custom fields created! ===" echo "" echo "Next step: Get field IDs and add options" echo "" # ============================================ # 6. GET CUSTOM FIELD IDS # ============================================ echo "=== Getting Custom Field IDs ===" curl -s -X GET \ "${JIRA_URL}/rest/api/3/field" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" | jq '[.[] | select(.custom == true) | {id: .id, name: .name}]' echo "" echo "Save these IDs! You'll need them for the next step." echo "" # ============================================ # 7. ADD OPTIONS TO SELECT FIELDS # ============================================ # Replace FIELD_ID with actual IDs from step 6 echo "=== Adding Options to Select Fields ===" echo "Replace FIELD_ID placeholders with actual IDs!" echo "" # Template for adding options (run separately for each field): : << 'OPTIONS_TEMPLATE' # First, get the context ID for the field FIELD_ID="customfield_XXXXX" curl -s -X GET \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context" \ -H "Authorization: Basic ${JIRA_AUTH}" # Then add options (replace CONTEXT_ID with actual ID) CONTEXT_ID="XXXXX" # Lead Source Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Website", "disabled": false}, {"value": "Referral", "disabled": false}, {"value": "LinkedIn", "disabled": false}, {"value": "Webinar", "disabled": false}, {"value": "Cold Outreach", "disabled": false}, {"value": "Partner", "disabled": false}, {"value": "Google Ads", "disabled": false}, {"value": "Social Media", "disabled": false}, {"value": "Other", "disabled": false} ] }' # Lead Status Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "New", "disabled": false}, {"value": "Contacted", "disabled": false}, {"value": "Qualified", "disabled": false}, {"value": "Proposal Sent", "disabled": false}, {"value": "Negotiation", "disabled": false}, {"value": "Won", "disabled": false}, {"value": "Lost", "disabled": false}, {"value": "On Hold", "disabled": false} ] }' # Service Package Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Starter (£450-850)", "disabled": false}, {"value": "Growth (£950-1900)", "disabled": false}, {"value": "Pro (£2400-6000)", "disabled": false}, {"value": "Enterprise (£10K+)", "disabled": false}, {"value": "Custom", "disabled": false} ] }' # Invoice Status Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Draft", "disabled": false}, {"value": "Sent", "disabled": false}, {"value": "Viewed", "disabled": false}, {"value": "Partial Payment", "disabled": false}, {"value": "Paid", "disabled": false}, {"value": "Overdue", "disabled": false}, {"value": "Cancelled", "disabled": false} ] }' # Contract Type Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Service Agreement", "disabled": false}, {"value": "NDA", "disabled": false}, {"value": "Maintenance Contract", "disabled": false}, {"value": "Partnership Agreement", "disabled": false}, {"value": "Subcontractor Agreement", "disabled": false}, {"value": "Other", "disabled": false} ] }' # Ticket Category Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Bug Report", "disabled": false}, {"value": "Feature Request", "disabled": false}, {"value": "How-To Question", "disabled": false}, {"value": "Integration Issue", "disabled": false}, {"value": "Performance Issue", "disabled": false}, {"value": "Billing Question", "disabled": false}, {"value": "Other", "disabled": false} ] }' # SLA Priority Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Critical (2h response)", "disabled": false}, {"value": "High (4h response)", "disabled": false}, {"value": "Medium (8h response)", "disabled": false}, {"value": "Low (24h response)", "disabled": false} ] }' # Environment Options curl -s -X POST \ "${JIRA_URL}/rest/api/3/field/${FIELD_ID}/context/${CONTEXT_ID}/option" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "options": [ {"value": "Development", "disabled": false}, {"value": "Staging", "disabled": false}, {"value": "Production", "disabled": false} ] }' OPTIONS_TEMPLATE # ============================================ # 8. COMPONENTS FOR PROD PROJECT # ============================================ echo "=== Creating Components for PROD ===" COMPONENTS=( "Website-Frontend|Next.js/React UI, landing pages" "Website-Backend|API endpoints, forms processing" "Website-CMS|Content management, blog" "Integrations|Calendly, contact forms, analytics" "SEO|Meta tags, sitemap, Google Analytics" "Design-Assets|Images, icons, brand elements" "n8n-Workflows|Automation workflows" "Infrastructure|OVH, Docker, deployment" ) for comp in "${COMPONENTS[@]}"; do IFS='|' read -r name desc <<< "$comp" curl -s -X POST \ "${JIRA_URL}/rest/api/3/component" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d "{ \"name\": \"$name\", \"description\": \"$desc\", \"project\": \"PROD\", \"leadAccountId\": \"712020:7ea4a2d0-a562-4e28-beea-1e77538886b4\", \"assigneeType\": \"COMPONENT_LEAD\" }" echo "Created component: $name" sleep 1 done # ============================================ # 9. SAVED FILTERS # ============================================ echo "=== Creating Saved Filters ===" FILTERS=( "PROD - All Open|project = PROD AND status != Done ORDER BY priority DESC" "PROD - My Tasks|project = PROD AND assignee = currentUser() AND status != Done" "PROD - Bugs|project = PROD AND type = Bug AND status != Done" "PROD - Current Sprint|project = PROD AND sprint in openSprints()" "MARK - All Leads|project = MARK AND summary ~ Lead ORDER BY created DESC" "MARK - Hot Leads|project = MARK AND priority in (Highest, High) AND status != Done" "MARK - Won Deals|project = MARK AND status = Won" "MARK - Pipeline Value|project = MARK AND status not in (Won, Lost)" "SUPP - Open Tickets|project = SUPP AND status != Done ORDER BY priority DESC" "SUPP - Unassigned|project = SUPP AND assignee is EMPTY AND status != Done" "SUPP - Critical|project = SUPP AND priority = Highest AND status != Done" "SUPP - Overdue|project = SUPP AND due < now() AND status != Done" "OPS - Pending Invoices|project = OPS AND summary ~ Invoice AND status != Done" "OPS - Overdue Invoices|project = OPS AND summary ~ Invoice AND due < now() AND status != Done" "OPS - Active Contracts|project = OPS AND summary ~ Contract AND status != Done" "EXEC - All Critical|priority = Highest AND status != Done" "EXEC - All Overdue|due < now() AND status != Done" "EXEC - This Week|created >= -7d ORDER BY created DESC" "EXEC - Unassigned|assignee is EMPTY AND status != Done" "My Tasks - All|assignee = currentUser() AND status != Done ORDER BY due ASC" ) for filter in "${FILTERS[@]}"; do IFS='|' read -r name jql <<< "$filter" curl -s -X POST \ "${JIRA_URL}/rest/api/3/filter" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d "{ \"name\": \"$name\", \"jql\": \"$jql\", \"favourite\": true, \"sharePermissions\": [{\"type\": \"authenticated\"}] }" echo "Created filter: $name" sleep 1 done # ============================================ # 10. DASHBOARDS # ============================================ echo "=== Creating Dashboards ===" curl -s -X POST \ "${JIRA_URL}/rest/api/3/dashboard" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Executive Overview", "description": "High-level business metrics and KPIs", "sharePermissions": [{"type": "authenticated"}] }' echo "Created: Executive Overview" sleep 1 curl -s -X POST \ "${JIRA_URL}/rest/api/3/dashboard" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Engineering Dashboard", "description": "Development progress, bugs, and technical tasks", "sharePermissions": [{"type": "authenticated"}] }' echo "Created: Engineering Dashboard" sleep 1 curl -s -X POST \ "${JIRA_URL}/rest/api/3/dashboard" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Sales & Marketing", "description": "Lead funnel, campaigns, and sales pipeline", "sharePermissions": [{"type": "authenticated"}] }' echo "Created: Sales & Marketing" sleep 1 curl -s -X POST \ "${JIRA_URL}/rest/api/3/dashboard" \ -H "Authorization: Basic ${JIRA_AUTH}" \ -H "Content-Type: application/json" \ -d '{ "name": "Support Dashboard", "description": "Ticket queue, SLA status, and customer satisfaction", "sharePermissions": [{"type": "authenticated"}] }' echo "Created: Support Dashboard" sleep 1 echo "" echo "=== SETUP COMPLETE ===" echo "" echo "Next manual steps:" echo "1. Get custom field IDs and add options (see section 7)" echo "2. Configure dashboard gadgets via UI" echo "3. Set up automation rules via UI" echo "4. Configure workflows via UI (or use Workflow API for Company-managed projects)" echo ""