diff --git a/jira-commenter.sh b/jira-commenter.sh new file mode 100755 index 0000000..6fc18f4 --- /dev/null +++ b/jira-commenter.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash +USER=":, 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}