NOTICK - Allow JIRA user name to be provided in an environment variable (#4202)

This commit is contained in:
Tommy Lillehagen 2018-11-08 18:19:10 +00:00 committed by GitHub
parent d4474e87e1
commit 7c4eaf2f01
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 10 deletions

View File

@ -58,7 +58,9 @@ This will create a new sub-task under each of the test tickets for `<PRODUCT>` `
## Options
Each command described above has a set of additional options. More specifically, if you want to use a particular JIRA user instead of being prompted for a user name every time, you can specify `--user <USER>`. For verbose logging, you can supply `--verbose` or `-v`. And to auto-reply to the prompt of whether to proceed or not, provide `--yes` or `-y`.
Each command described above has a set of additional options. More specifically, if you want to use a particular JIRA user instead of being prompted for a user name every time, you can specify `--user <USER>`. You can also provide the user name in the environment variable, `JIRA_USER`.
For verbose logging, you can supply `--verbose` or `-v`. And to auto-reply to the prompt of whether to proceed or not, provide `--yes` or `-y`.
There is also a useful dry-run option, `--dry-run` or `-d`, that lets you run through the command without creating any tickets or applying any changes to JIRA.

View File

@ -1,7 +1,7 @@
# {{{ Dependencies
from __future__ import print_function
import sys
import sys, os
try:
from getpass import getpass
@ -41,9 +41,13 @@ def confirm(message, auto_yes=False):
# {{{ login(account, user, password, use_keyring) - Present user with login prompt and return the provided username and password. If use_keyring is true, use previously provided password (if any)
def login(account, user=None, password=None, use_keyring=True):
if not user:
user = prompt('Username: ')
user = u'{}@r3.com'.format(user) if '@' not in user else user
if not user: return (None, None)
if 'JIRA_USER' not in os.environ:
user = prompt('Username: ')
user = u'{}@r3.com'.format(user) if '@' not in user else user
if not user: return (None, None)
else:
user = os.environ['JIRA_USER']
print('Username: {}'.format(user))
else:
user = u'{}@r3.com'.format(user) if '@' not in user else user
print('Username: {}'.format(user))

View File

@ -16,10 +16,10 @@ try:
def red(message): return colored(message, 'red')
def yellow(message): return colored(message, 'yellow')
def faint(message): return colored(message, 'white', attrs=['dark'])
def on_green(message): return colored(message, 'white', 'on_green')
def on_red(message): return colored(message, 'white', 'on_red')
def blue_on_white(message): return colored(message, 'blue', 'on_white')
def yellow_on_white(message): return colored(message, 'yellow', 'on_white')
def on_green(message): return colored(message, 'green')
def on_red(message): return colored(message, 'red')
def blue_on_white(message): return colored(message, 'blue')
def yellow_on_white(message): return colored(message, 'yellow')
except:
def blue(message): return u'[{}]'.format(message)
def green(message): return message
@ -159,7 +159,10 @@ def create_version(args):
jira.jira.create_version(name=version, project=project, description=version)
print(u' {} - Created version for project {}'.format(green('SUCCESS'), blue(project)))
except Exception as error:
print(u' {} - Failed to version: {}'.format(red('FAIL'), error))
if args.verbose:
print(u' {} - Failed to version: {}'.format(red('FAIL'), error))
else:
print(u' {} - Failed to version: {}'.format(red('FAIL'), error.text))
print()