In this page
Terminology
REST API reference
/commit-policy
/commit-policy/{policy-id}/clone
/commit-policy/{policy-id}/verification
/hook-script/{vcs}/{os}/{policy-id}
/hook-script/{hook-script-pack-id}
Overview
Better Commit Policy for Jira provides a REST API for developers to implement custom use cases.
Examples:
- Building custom hook scripts for the already supported Version Control Systems. When your system is covered, but you need some modifications in the hook's behavior.
- Creating new hook scripts to adapt the app's verification functionality to unsupported Version Control Systems. When your system is not yet supported, but you want to leverage the app.
- Developing maintenance scripts that do something in your repositories. For example, if you want to mass-install hook scripts to hundreds of repositories without using the UI.
The Better Commit Policy's REST API is a natural extension to Jira's core REST API. It uses the same semantics: you can authenticate to Jira and call REST methods the same exact way with both of those. Learn more about using the Jira REST API in the Jira Development documentation.
Please note that the set of the API methods is fairly limited at the moment, but we are open to requests to extend it.
Terminology
Since Better Commit Policy for Jira supports several Version Control Systems, each with its own concepts and terminology, we have to clarify the meaning of changeset in this documentation. In our terminology, a changeset consists of information about one or more commits, plus some additional metadata about the changeset itself.
REST API reference
/commit-policy
Returns the list of the existing commit policies. | |
1.3.0 | |
http://jira.mycompany.com/rest/commit-policy/1.0/commit-policy |
|
GET | |
Sample JSON response: [ { "id": 1, "name": "ACME policy", "description": "This is the policy for all our projects at Acme, Inc.", "rejectionMessage": "You commit violates the ACME policy!", "enabled": true, "bypassMergeCommits": true, /* since 3.0.0 */ "bypassExistingCommits": true /* since 3.0.0 */ } ] |
/commit-policy/{policy-id}/clone
Clones the commit policy with the passed ID by using a generated name and by copying its properties and rules. | |
3.4.0 | |
http://jira.mycompany.com/rest/commit-policy/1.0/commit-policy/5/clone |
|
POST | |
Sample JSON response: [ { "id": 6, "name": "Copy of ACME Policy", /* name cloned as "Copy of <original name>" */ "description": "This is the policy for all our projects at Acme, Inc.", "rejectionMessage": "You commit violates the ACME policy!", "enabled": true, "bypassMergeCommits": true, "bypassExistingCommits": true } ] |
/commit-policy/{policy-id}/verification
Verifies a changeset against a policy. | |||||||||||||||||||||||||||||||||||||
1.0.0 | |||||||||||||||||||||||||||||||||||||
http://jira.mycompany.com/rest/commit-policy/1.0/commit-policy/1/verification |
|||||||||||||||||||||||||||||||||||||
POST | |||||||||||||||||||||||||||||||||||||
Sample JSON request:
{ "tags": [ { "name": "added-tag", "action": "a" } ], "branches": [ { "name": "deleted-branch", "action": "d" } ], "commits": [ { "id": "04c5ad0", "branch": "master", "isMerge": false, "isExisting": false, "userName": "johndoe <john.doe@acme.com>", "message": "Initial import", "files": [ { "path": "foobar.txt", "action": "a" } ] } ], "vcs": "git", "diagnosticMode": false, "hookScriptVersion": "3.0.0", "hookScriptFeatures": [], "repositoryId": "c:\\git_repos\\super_duper_product" }
{ "ok": false "rejectionMessageFormatted": "======================================================================== REJECTED! ======================================================================== 1.1 COMMIT [04c5ad0] on [master] Exactly one issue key must be mentioned in the commit message \"Initial import\" ======================================================================== REJECTED! ========================================================================" } |
/hook-script/{vcs}/{os}/{policy-id}
Generates a hook script pack and returns its reference ID. See the next API call about using this ID. | |
1.0.0 | |
http://jira.mycompany.com/rest/commit-policy/1.0/hook-script/git/linux/1 |
|
POST | |
Sample JSON response: { "packId": "58389b1dc1e55684c2804c561ba5e52d" } |
/hook-script/{hook-script-pack-id}
Downloads a previously generated hook script pack. | |
1.0.0 | |
http://jira.mycompany.com/rest/commit-policy/1.0/hook-script/58389b1dc1e55684c2804c561ba5e52d |
|
GET | |
Binary response, the hook script pack in ZIP format. |
Questions?
Ask us any time.