Skip to content

Instantly share code, notes, and snippets.

@kmonsoor
Created May 24, 2019 19:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kmonsoor/f4cc53a0c89e2b11843cb46748055cd6 to your computer and use it in GitHub Desktop.
Save kmonsoor/f4cc53a0c89e2b11843cb46748055cd6 to your computer and use it in GitHub Desktop.
Jira-Python : Create versions for project
# replce server address with actual Jira host for your case
options = {'server': 'https://jira.atlassian.com'}
#login
jira = JIRA(options, basic_auth=(os.environ['JIRA_USERNAME'], os.environ['JIRA_PASSWORD']))
#get currently available version names
project = jira.project('PROJECT-KEY')
versions = jira.project_versions(project)
current_versions = [v.name for v in reversed(versions)]
for number in range(0, 82):
vname = 'v' + str(number) + '.0.0'
# check in the existing version names
if vname in current_versions:
print(vname, ": exists")
else:
# try to create new
try:
version = jira.create_version(name=vname, project='PROJECT-KEY')
print(vname, ": created, all good")
except:
print(vname, ": creation failed")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment