{"id":16569983,"url":"https://github.com/andygrunwald/jitic","last_synced_at":"2025-06-25T20:07:22.738Z","repository":{"id":36181268,"uuid":"40485401","full_name":"andygrunwald/jitic","owner":"andygrunwald","description":"The JIRA Ticket Checker - Checks the existence of one or more ticket in the JIRA issue tracker","archived":false,"fork":false,"pushed_at":"2021-06-25T14:08:43.000Z","size":55,"stargazers_count":34,"open_issues_count":1,"forks_count":4,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-06-14T05:35:31.719Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/andygrunwald.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"github":"andygrunwald","custom":"https://paypal.me/andygrunwald"}},"created_at":"2015-08-10T13:56:42.000Z","updated_at":"2025-05-05T16:18:44.000Z","dependencies_parsed_at":"2022-07-09T14:30:28.390Z","dependency_job_id":null,"html_url":"https://github.com/andygrunwald/jitic","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/andygrunwald/jitic","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fjitic","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fjitic/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fjitic/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fjitic/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/andygrunwald","download_url":"https://codeload.github.com/andygrunwald/jitic/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/andygrunwald%2Fjitic/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261945376,"owners_count":23234237,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-11T21:16:12.390Z","updated_at":"2025-06-25T20:07:22.676Z","avatar_url":"https://github.com/andygrunwald.png","language":"Go","funding_links":["https://github.com/sponsors/andygrunwald","https://paypal.me/andygrunwald"],"categories":[],"sub_categories":[],"readme":"# jitic - JIRA Ticket Checker\n\n[![Build Status](https://travis-ci.org/andygrunwald/jitic.svg?branch=master)](https://travis-ci.org/andygrunwald/jitic)\n\n*jitic* - the **JI**RA **Ti**cket **C**hecker - checks the existence of one or more issues in the [JIRA](https://www.atlassian.com/software/jira) issue tracker. If the issue exists we will shutdown with exit code 0. Otherwise with 1.\n\n![jitic - the JIRA Ticket Checker](./img/jitic.png \"jitic - the JIRA Ticket Checker\")\n\n1. [Usage](#usage)\n\t1. \t[Examples](#examples)\n2. [Use cases](#use-cases)\n\t1. [Subversion \"pre-commit\" hook](#subversion-pre-commit-hook)\n\t2. [Git \"pre-receive\" hook](#git-pre-receive-hook)\n3. [License](#license)\n\n## Usage\n\n```\nUsage of ./jitic:\n  -issues string\n        Message to retrieve the issues from.\n  -pass string\n        JIRA Password.\n  -stdin\n        If set to true you can stream \"-issues\" to stdin instead of an argument. If set \"-issues\" will be ignored.\n  -url string\n        JIRA instance URL (format: scheme://[username[:password]@]host[:port]/).\n  -user string\n        JIRA Username.\n  -verbose\n        If activated more information will be written to stdout .\n  -version\n        Outputs the version number and exits.\n```\n\n### Examples\n\nCheck if issue [MESOS-3136](https://issues.apache.org/jira/browse/MESOS-3136) exists in [https://issues.apache.org/jira/](https://issues.apache.org/jira/) from parameter:\n\n```bash\n$ ./jitic -url=\"https://issues.apache.org/jira/\" -issues=\"MESOS-3136 - Fix command health check\"; echo \"Exit code: $?\"\nExit code: 0\n```\n\nCheck if issue [MESOS-3136](https://issues.apache.org/jira/browse/MESOS-3136) exists in [https://issues.apache.org/jira/](https://issues.apache.org/jira/) from stdin.\n\n```bash\n$ echo \"MESOS-3136 - Fix command health check\" | ./jitic -url=\"https://issues.apache.org/jira/\" -stdin; echo \"Exit code: $?\"\nExit code: 0\n```\n\nCheck if a fake issue MESOS-123456 exists in [https://issues.apache.org/jira/](https://issues.apache.org/jira/) from parameter:\n\n```bash\n$ ./jitic -url=\"https://issues.apache.org/jira/\" -issues=\"MESOS-123456 - Not existing issue\" -verbose; echo \"Exit code: $?\"\n2017/11/28 15:41:26 JIRA Request for issue MESOS-123456 returned 404 Not Found (404)\n```\n\n## Use cases\n\n### Subversion \"pre-commit\" hook\n\nSee [Implementing Repository Hooks](http://svnbook.red-bean.com/en/1.7/svn.reposadmin.create.html#svn.reposadmin.create.hooks) and [pre-commit](http://svnbook.red-bean.com/en/1.7/svn.ref.reposhooks.pre-commit.html).\n\nHow a pre-commit hook can look like:\n```sh\n#!/bin/sh\n\nREPOS=\"$1\"\nTXN=\"$2\"\n\n# Get the commit message\nSVNLOOK=/usr/bin/svnlook\nCOMMIT_MSG=$($SVNLOOK log -t \"$TXN\" \"$REPOS\")\n\nJITIC=/usr/bin/jitic\nJIRA_URL=\"https://jira.example.org/\"\nJIRA_USERNAME=\"JIRA-API\"\nJIRA_PASSWORD=\"SECRET-PASSWORD\"\n\n# Exit on all errors.\nset -e\n\n# Auth against JIRA and check if the issue(s) exists\n$JITIC -url=\"$JIRA_URL\" -user=\"$JIRA_USERNAME\" -pass=\"$JIRA_PASSWORD\" -issues=\"$COMMIT_MSG\"\n\n# All checks passed, so allow the commit.\nexit 0\n```\n\n**Pro-Tip**: Set the variables *JIRA_USERNAME* and *JIRA_PASSWORD* in a seperate file and import this file via [*source*](http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html) into the hook.\nWith this you can store the pre-commit hook itself in git + deploy it with configuration management.\n\n### Git \"pre-receive\" hook\n\nSee [Customizing Git - Git Hooks](https://git-scm.com/book/it/v2/Customizing-Git-Git-Hooks) and [A reasonable git pre-receive-hook](https://gist.github.com/caniszczyk/1327469) and [Can git pre-receive hooks evaulate the incoming commit?](http://stackoverflow.com/questions/22546393/can-git-pre-receive-hooks-evaulate-the-incoming-commit).\n\nHow a pre-receive hook can look like:\n```sh\n#!/bin/sh\n\nGIT=/usr/local/bin/git\nJITIC=/usr/bin/jitic\nJIRA_URL=\"https://jira.example.org/\"\nJIRA_USERNAME=\"JIRA-API\"\nJIRA_PASSWORD=\"SECRET-PASSWORD\"\n\nFAIL=\"\"\n\nvalidate_ref()\n{\n\t# Arguments\n\toldrev=$($GIT rev-parse $1)\n\tnewrev=$($GIT rev-parse $2)\n\trefname=\"$3\"\n\n\t# $oldrev / $newrev are commit hashes (sha1) of git\n\t# $refname is the full name of branch (refs/heads/*) or tag (refs/tags/*)\n\t# $oldrev could be 0s which means creating $refname\n\t# $newrev could be 0s which means deleting $refname\n\n\tcase \"$refname\" in\n\t\trefs/heads/*)\n\t\t\t# We currently only care about updating branches.\n\t\t\t# If you want to take care for deleting branched check this:\n\t\t\t#   if [ 0 -ne $(expr \"$newrev\" : \"0*$\") ]; then\n\t\t\t#       # Your code here\n\t\t\t#   fi\n\n\t\t\t# Pushing a new branch\n\t\t\tif [ 0 -ne $(expr \"$oldrev\" : \"0*$\") ]; then\n\t\t\t\tCOMMITS_TO_CHECK=$($GIT rev-list $newrev --not --branches=*)\n\n\t\t\t# Updating an existing branch\n\t\t\telse\n\t\t\t\tCOMMITS_TO_CHECK=$($GIT rev-list $oldrev..$newrev)\n\t\t\tfi\n\n\t\t\t# If we push an new, but empty branch we can exit early.\n\t\t\t# In this case there are no commits to check.\n\t\t\tif [ -z \"$COMMITS_TO_CHECK\" ]; then\n\t\t\t\treturn\n\t\t\tfi\n\n\t\t\t# Get all commits, loop over and check if there are valid JIRA tickets\n\t\t\twhile read REVISION ; do\n\t\t\t\tCOMMIT_MESSAGE=$($GIT log --pretty=format:\"%B\" -n 1 $REVISION)\n\n\t\t\t\t$JITIC -url=\"$JIRA_URL\" -user=\"$JIRA_USERNAME\" -pass=\"$JIRA_PASSWORD\" -issues=\"$COMMIT_MESSAGE\"\n\t\t\t\tif [ $? != 0 ]; then\n\t\t\t\t\tFAIL=1\n\t\t\t\t\techo \u003e\u00262 \"... in revision $REVISION\"\n\t\t\t\tfi\n\t\t\tdone \u003c\u003c\u003c \"$COMMITS_TO_CHECK\"\n\n\t\t\treturn\n\t\t\t;;\n\t\trefs/tags/*)\n\t\t\t# Support for tags (new / delete) needs to be done.\n\t\t\t# Things we need to check:\n\t\t\t#   * Get all commits from the new tag that are NOT checked yet\n\t\t\t#     (checked means by jitic). Something like commits which are\n\t\t\t#     not pushed yet, but the tag was pushed.\n\t\t\t# I think we don`t need to care about deleted branches yet.\n\t\t\t;;\n\t\t*)\n\t\t\tFAIL=1\n\t\t\techo \u003e\u00262 \"\"\n\t\t\techo \u003e\u00262 \"*** pre-receive hook does not understand ref $refname in this repository. ***\"\n\t\t\techo \u003e\u00262 \"*** Contact the repository administrator. ***\"\n\t\t\techo \u003e\u00262 \"\"\n\t\t\t;;\n\tesac\n}\n\nwhile read OLD_REVISION NEW_REVISION REFNAME\ndo\n\tvalidate_ref $OLD_REVISION $NEW_REVISION $REFNAME\ndone\n\nif [ -n \"$FAIL\" ]; then\n\texit $FAIL\nfi\n```\n\n**Pro-Tip**: Set the variables *JIRA_USERNAME* and *JIRA_PASSWORD* in a seperate file and import this file via [*source*](http://www.tldp.org/HOWTO/Bash-Prompt-HOWTO/x237.html) into the hook.\nWith this you can store the pre-commit hook itself in git + deploy it with configuration management.\n\n## License\n\nThis project is released under the terms of the [MIT license](http://en.wikipedia.org/wiki/MIT_License).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fjitic","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fandygrunwald%2Fjitic","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fandygrunwald%2Fjitic/lists"}