jira-clien.py

#We want following to check also

Jira must not be a story or epic.
Jira must be in-process status.

#!/usr/bin/python

  1. JIRA commit acceptance python client for SVN
  2. Author: istvan.vamosi@midori.hu
  3. $Id: jira-client.py 10144 2007-09-12 10:13:37Z ferenc.kiss $

import os
import sys
import urlparse
import xmlrpclib

  1. configure JIRA access
  2. ("projectKey" can contain multiple comma-separated JIRA project keys like "projectKey = 'TST,ARP'".
  3. If you specify multiple keys, the commit will be accepted if at least one project listed accepts it.
  4. Or you can specify "projectKey = '*'" to force using the global commit acceptance settings if you don't
  5. want to specify any exact project key.)
    jiraBaseURL = 'https://jira.crossview.com'
    jiraLogin = 'SN'
    jiraPassword = 'TESTABC'
    projectKey = 'ABC'
  1. configure svnlook path
    svnlookPath = '/usr/local/bin/svnlook'
    #svnlookPath = 'C:\\Progra~1\\svn-win32-1.4.0\\bin
    svnlook.exe'
  1. get committer
    try:
    f = os.popen(svnlookPath + ' author ' + sys.argv[1] + ' --transaction ' + sys.argv[2])
    committer = f.read()
    if f.close():
    raise 1
    committer = committer.rstrip("\n\r")
    except:
    print >> sys.stderr, 'Unable to get committer with svnlook.'
    sys.exit(1)
  1. get commit message
    try:
    f = os.popen(svnlookPath + ' log ' + sys.argv[1] + ' --transaction ' + sys.argv[2])
    commitMessage = f.read()
    if f.close():
    raise 1
    commitMessage = commitMessage.rstrip('\n\r')
    except:
    print >> sys.stderr, 'Unable to get commit message with svnlook.'
    sys.exit(1)
  1. print arguments
    print >> sys.stderr, 'Committer: ' + committer
    print >> sys.stderr, 'Commit message: "' + commitMessage + '"'
  1. invoke JIRA web service
    try:
    s = xmlrpclib.ServerProxy(urlparse.urljoin(jiraBaseURL, '/rpc/xmlrpc'))
    acceptance, comment = s.commitacc.acceptCommit(jiraLogin, jiraPassword, committer, projectKey, commitMessage).split('|');
    except:
    acceptance, comment = ['false', 'Unable to connect to the JIRA server at "' + jiraBaseURL + '".']

if acceptance == 'true':
print >> sys.stderr, 'Commit accepted.'
sys.exit(0)
else:
print >> sys.stderr, 'Commit rejected: ' + comment
sys.exit(1)

1 answer

Save the programming and use the Commit Policy Plugin.

Unlike the Commit Acceptance Plugin, it can check if the issue keys included in the commit message are matching a JQL. For instance you can use a check with this JQL, and this requires exactly zero programming:

type NOT IN (Story, Epic) AND status = In-process

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jun 12, 2018 in Bitbucket

Do you use any Atlassian products for your personal projects?

After spinning my wheels trying to get organized enough to write a book for National Novel Writing Month (NaNoWriMo) I took my affinity for Atlassian products from my work life and decided to tr...

23,239 views 26 12
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you