Files
agentrunner/youtrack-comment
CI System 5903b69b2d Initial commit: ClearGrow Agent Runner
Automated task orchestration system for YouTrack + Gitea + Woodpecker CI:

- runner.py: Main orchestration engine with state machine workflow
- agent.py: Claude Code subprocess pool management
- youtrack_client.py: YouTrack API wrapper
- gitea_client.py: Gitea API + git CLI operations
- woodpecker_client.py: CI build monitoring
- webhook_server.py: Real-time event handling
- prompts/: Agent prompt templates (developer, qa, librarian)

Workflow: Ready → In Progress → Build → Verify → Document → Review → Done

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2025-12-10 21:05:31 -07:00

54 lines
1.6 KiB
Bash
Executable File

#!/bin/bash
# YouTrack comment helper for Claude agents
# Usage: youtrack-comment <issue-id> <comment-text>
# e.g.: youtrack-comment CG-48 "## Agent Progress\n\nWork completed."
set -e
ISSUE_ID="$1"
COMMENT_TEXT="$2"
if [ -z "$ISSUE_ID" ] || [ -z "$COMMENT_TEXT" ]; then
echo "Usage: youtrack-comment <issue-id> <comment-text>" >&2
echo "Example: youtrack-comment CG-48 'Work completed successfully'" >&2
exit 1
fi
# Load config from yaml
CONFIG_FILE="/opt/agent_runner/config.yaml"
if [ ! -f "$CONFIG_FILE" ]; then
echo "Error: Config file not found: $CONFIG_FILE" >&2
exit 1
fi
# Extract YouTrack settings (simple grep/sed approach)
YOUTRACK_URL=$(grep -A2 "^youtrack:" "$CONFIG_FILE" | grep "base_url:" | sed 's/.*base_url: *//' | tr -d ' ')
YOUTRACK_TOKEN=$(grep -A3 "^youtrack:" "$CONFIG_FILE" | grep "token:" | sed 's/.*token: *//' | tr -d ' ')
if [ -z "$YOUTRACK_URL" ] || [ -z "$YOUTRACK_TOKEN" ]; then
echo "Error: YouTrack URL or token not configured in $CONFIG_FILE" >&2
exit 1
fi
# Post comment via YouTrack API
# Note: Comment text needs to be JSON-escaped
JSON_PAYLOAD=$(jq -n --arg text "$COMMENT_TEXT" '{"text": $text}')
RESPONSE=$(curl -s -w "\n%{http_code}" -X POST \
-H "Authorization: Bearer $YOUTRACK_TOKEN" \
-H "Content-Type: application/json" \
-d "$JSON_PAYLOAD" \
"${YOUTRACK_URL}/api/issues/${ISSUE_ID}/comments")
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
BODY=$(echo "$RESPONSE" | sed '$d')
if [ "$HTTP_CODE" -ge 200 ] && [ "$HTTP_CODE" -lt 300 ]; then
echo "Comment added to $ISSUE_ID"
else
echo "Error adding comment to $ISSUE_ID: HTTP $HTTP_CODE" >&2
echo "$BODY" >&2
exit 1
fi