Skip to content

Commit

Permalink
Passing URL as environment variable
Browse files Browse the repository at this point in the history
Signed-off-by: Lukas Bednar <[email protected]>
  • Loading branch information
lukas-bednar committed Apr 30, 2024
1 parent ae7b8ac commit dfe184f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
4 changes: 2 additions & 2 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -198,11 +198,11 @@ 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 and username fields by setting the PYTEST_JIRA_PASSWORD, PYTEST_JIRA_USERNAME and
PYTEST_JIRA_TOKEN environment variables:
Alternatively, you can set the url, password, username and token fields using relevant environment variables:

.. code:: sh
export PYTEST_JIRA_URL="https://..."
export PYTEST_JIRA_PASSWORD="FOO"
export PYTEST_JIRA_USERNAME="BAR"
export PYTEST_JIRA_TOKEN="TOKEN"
Expand Down
7 changes: 5 additions & 2 deletions pytest_jira.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
SKIP = 'skip'
IGNORE = 'ignore'
PLUGIN_NAME = "jira_plugin"
URL_ENV_VAR = 'PYTEST_JIRA_URL'
PASSWORD_ENV_VAR = 'PYTEST_JIRA_PASSWORD'
USERNAME_ENV_VAR = 'PYTEST_JIRA_USERNAME'
TOKEN_ENV_VAR = 'PYTEST_JIRA_TOKEN'
Expand Down Expand Up @@ -544,9 +545,11 @@ def pytest_configure(config):
if not resolved_resolutions:
resolved_resolutions = []

if config.getvalue('jira') and config.getvalue('jira_url'):
if config.getvalue('jira') and (
os.getenv(URL_ENV_VAR) or config.getvalue('jira_url')
):
jira_connection = JiraSiteConnection(
config.getvalue('jira_url'),
os.getenv(URL_ENV_VAR) or config.getvalue('jira_url'),
os.getenv(USERNAME_ENV_VAR) or config.getvalue('jira_username'),
os.getenv(PASSWORD_ENV_VAR) or config.getvalue('jira_password'),
config.getvalue('jira_verify'),
Expand Down

0 comments on commit dfe184f

Please sign in to comment.