Skip to content

Commit

Permalink
feat: jira commenter script
Browse files Browse the repository at this point in the history
  • Loading branch information
lemeurherveCB committed Feb 11, 2022
1 parent 81d01af commit 0cac652
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions jira-commenter.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
#!/usr/bin/env bash
USER="<your-jenkins-username"
PWD="<your-jenkins-pwd>"
JIRA="https://issues.jenkins.io"
GITHUB="https://github.com/jenkins-infra/helpdesk/issues/"
FILE="jira-keys-to-github-id.txt" # with each line containing <JENKINS-ISSUE-KEY>:<GITHUB-ISSUE-KEY>, ex: "INFRA-545:415"

while IFS=':' read -ra ADDR; do
echo "processing:: $GITHUB${ADDR[1]} >> ${JIRA}/browse/${ADDR[0]}"
ID=${ADDR[1]}
KEY=${ADDR[0]}
BODY="For your information, [all INFRA issues|${JIRA}/projects/INFRA/issues/] related to the [Jenkins Infrastructure project|https://www.jenkins.io/projects/infrastructure/] have been transferred to Github: ${GITHUB}\n\nHere is the direct link to this issue in Github: ${GITHUB}/${ID}\nAnd here is the link to a search for related issues: ${GITHUB}?q=%22${KEY}%22\n\n(Note: this is an automated bulk comment)"
# https://developer.atlassian.com/server/jira/platform/jira-rest-api-examples/#adding-a-comment
curl \
-D- \
-u ${USER}:${PWD} \
-X POST \
--data "{\"body\": \"${BODY}\"}" \
-H "Content-Type: application/json" \
"${JIRA}/rest/api/2/issue/${KEY}/comment"

done <${FILE}

0 comments on commit 0cac652

Please sign in to comment.