ira を始めて使った時のメモ
また、API で操作を行うまでをやってみる
始めに
- アカウント作成
- Jira を作成
- 適当な Space を作成
API キーの発行
- https://id.atlassian.com/manage-profile/security/api-tokens にアクセス
- トークンを作成
- Name は適当にわかりやすいものにする
- 生成されるトークンをメモしておく
Issue を API から作る
とりあえず簡単に試したいので curl で試す
# 1. 環境変数をセット(自分の値に置き換える)
export JIRA_DOMAIN="myteam"
export JIRA_EMAIL="taro@example.com"
export JIRA_API_TOKEN="..."
export JIRA_PROJECT_KEY="DOA"
# 2. Issue を作成
curl -X POST "https://${JIRA_DOMAIN}.atlassian.net/rest/api/3/issue" \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n "${JIRA_EMAIL}:${JIRA_API_TOKEN}" | base64)" \
-d '{
"fields": {
"project": { "key": "'"${JIRA_PROJECT_KEY}"'" },
"summary": "[Test] DevOps Agent Investigation Created",
"description": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "This is a test issue created via API." }
]
}
]
},
"issuetype": { "name": "Bug" }
}
}'
{"id":"10001","key":"KAN-2","self":"https://EXAMPLE.atlassian.net/rest/api/3/issue/10001"} ➜ ~
成功すると Web アプリからも確認できる
Comments を追加してみる
URL 配下の形式
https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}/comment
issueIdOrKey は Issue 作成時のレスポンスから確認できているのでコレを使う
curl -X POST "https://${JIRA_DOMAIN}.atlassian.net/rest/api/3/issue/KAN-2/comment" \
-H "Content-Type: application/json" \
-H "Authorization: Basic $(echo -n "${JIRA_EMAIL}:${JIRA_API_TOKEN}" | base64)" \
-d '{
"body": {
"type": "doc",
"version": 1,
"content": [
{
"type": "paragraph",
"content": [
{ "type": "text", "text": "Investigation completed. Root cause: High CPU due to memory leak in service X." }
]
}
]
}
}'
OK