Skip to content

Commit

Permalink
Enable using envvar for username (#128)
Browse files Browse the repository at this point in the history
* Update docs

* Add env variable for username
  • Loading branch information
alblasco authored Dec 23, 2022
1 parent b1b7b93 commit 461c6c9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 3 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,13 @@ Usage
# connection_error_strategy [strict|skip|ignore] Choose how to handle connection errors
# return_jira_metadata = False (return Jira issue with metadata instead of boolean result)
You can set the password field by setting the PYTEST_JIRA_PASSWORD environment variable:
You can set the password and username fields by setting the PYTEST_JIRA_PASSWORD and PYTEST_JIRA_USERNAME
environment variables:

.. code:: sh
export PYTEST_JIRA_PASSWORD="FOO"
export PYTEST_JIRA_USERNAME="BAR"
Configuration options can be overridden with command line options as well.
For all available command line options run following command.
Expand Down
3 changes: 2 additions & 1 deletion pytest_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
IGNORE = 'ignore'
PLUGIN_NAME = "jira_plugin"
PASSWORD_ENV_VAR = 'PYTEST_JIRA_PASSWORD'
USERNAME_ENV_VAR = 'PYTEST_JIRA_USERNAME'


class JiraHooks(object):
Expand Down Expand Up @@ -513,7 +514,7 @@ def pytest_configure(config):
if config.getvalue('jira') and config.getvalue('jira_url'):
jira_connection = JiraSiteConnection(
config.getvalue('jira_url'),
config.getvalue('jira_username'),
os.getenv(USERNAME_ENV_VAR) or config.getvalue('jira_username'),
os.getenv(PASSWORD_ENV_VAR) or config.getvalue('jira_password'),
config.getvalue('jira_verify'),
config.getvalue('jira_token'),
Expand Down

0 comments on commit 461c6c9

Please sign in to comment.