Last active
October 8, 2024 13:22
-
-
Save Antoniozinchenko/300587670a18002e891672fbea032c43 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# generate jira api token with your account here https://id.atlassian.com/manage-profile/security/api-tokens | |
export JIRA_API_TOKEN=<YOUR_API_TOKEN_HERE> | |
# get current jira issue title | |
jira_title() | |
{ | |
BRANCH=$(git branch --show-current) | |
jira issue view "$BRANCH" --plain | sed -n '1p' | awk '{print $2}' | |
ISSUE_TITLE=$(jira issue view "$BRANCH" --plain | grep '#' | sed -n '1 p' | sed 's/#//' | awk '$1=$1') | |
echo "[$BRANCH] $ISSUE_TITLE" | |
} | |
# do git checkout to current active jira issue | |
jirastart() | |
{ | |
BRANCH=$(jira issue list -s "In Progress" -a$(jira me) --plain --columns key | sed -n '2 p') | |
git co $BRANCH || git co -b $BRANCH | |
} | |
jiracommit() | |
{ | |
git add . | |
MESSAGE=$(jira_title) | |
git commit -m "$MESSAGE" | |
} | |
# find ticket by branch name and move to "In Review" status | |
jirareview() | |
{ | |
jira issue move $(git branch --show-current) "<YOUR_JIRA_STATUS_HERE>" | |
} | |
# do commit and create pull request with current jira issue | |
jirapush() | |
{ | |
jiracommit | |
git push -u origin $(git branch --show-current) | |
gh pr create --title "$(git log -1 --pretty=%B)" --body "https://<YOUR_JIRA_DOMAIN>.atlassian.net/browse/$(git branch --show-current)" | |
if [[ $1 == "--review" ]]; then | |
jirareview | |
fi | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
CLI shortcuts for working with your jira
install jira-cli and qithub cli (gh) before you start
just use
jirastart
for finding first your jira issue which has status 'In Progress' and dogit checkout
with correct branch namewhen you finish with code edit just run
jirapush
for making commit and create pull request with issue titleif your want also to move ticket in jira board, just add
--review
flag