{"id":238,"date":"2022-02-02T13:15:00","date_gmt":"2022-02-02T18:15:00","guid":{"rendered":"http:\/\/sycured.127.0.0.1.sslip.io\/?p=238"},"modified":"2024-01-14T11:35:00","modified_gmt":"2024-01-14T16:35:00","slug":"ira-extract-key-from-commit","status":"publish","type":"post","link":"http:\/\/10.42.0.68:8080\/blog\/ira-extract-key-from-commit","title":{"rendered":"Jira – Extract the key from the commit"},"content":{"rendered":"\n

Sometimes, we need to get a Jira key for later usage.<\/p>\n\n\n\n

For example, we can need it to do some release notes or other things.<\/p>\n\n\n\n

This is the regex that I use with an example of usage.<\/p>\n\n\n\n\n\n\n\n

Regex<\/h2>\n\n\n\n

You need to replace PRJ by your project:<\/p>\n\n\n\n

'((PRJ-)+([0-9]*)?)'<\/code><\/pre>\n\n\n\n

Example of usage<\/h2>\n\n\n\n

Extract the Jira key from all commits between 2 tags:<\/p>\n\n\n\n

git log rs420..rs422  --pretty=oneline | grep -oE '((PRJ-)+([0-9]*)?)' | sort -u<\/code><\/pre>\n\n\n\n

This permits us to obtain a clear list like:<\/p>\n\n\n\n

PRJ-4056\nPRJ-4057\nPRJ-4105\nPRJ-4189<\/code><\/pre>\n\n\n\n

The job is done, very easily and can be used for a lot of things like interacting with Jira API if needed.<\/p>\n","protected":false},"excerpt":{"rendered":"

Sometimes, we need to get a Jira key for later usage. For example, we can need it to do some release notes or other things. This is the regex that I use with an example of usage.<\/p>\n","protected":false},"author":1,"featured_media":239,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"saved_in_kubio":false,"footnotes":""},"categories":[28],"tags":[30,15],"_links":{"self":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/238"}],"collection":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/comments?post=238"}],"version-history":[{"count":1,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/238\/revisions"}],"predecessor-version":[{"id":240,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/posts\/238\/revisions\/240"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media\/239"}],"wp:attachment":[{"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/media?parent=238"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/categories?post=238"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/10.42.0.68:8080\/wp-json\/wp\/v2\/tags?post=238"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}