From 1c99685755ebd2e9830b9deb438e7152c28dfa14 Mon Sep 17 00:00:00 2001 From: Eric Ball Date: Fri, 2 Aug 2019 14:08:06 -0700 Subject: [PATCH] Include auth credentials with release requests Also includes a small logging improvement. During troubleshooting, I found that it wasn't clear whether the credentials were being picked up successfully from lftools.ini. Having some feedback during a handled error will be much more helpful. Change-Id: I2fa49f11ccb242296db9875e3018a8adf8b70f18 Signed-off-by: Eric Ball --- lftools/nexus/cmd.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/lftools/nexus/cmd.py b/lftools/nexus/cmd.py index d43bc314..377bfed6 100644 --- a/lftools/nexus/cmd.py +++ b/lftools/nexus/cmd.py @@ -46,6 +46,8 @@ def get_credentials(settings_file, url=None): password = config.get_setting("nexus", "password") except (configparser.NoOptionError, configparser.NoSectionError): + log.info("Failed to get nexus credentials; using empty username " + "and password.") return {"nexus": url, "user": "", "password": ""} return {"nexus": url, "user": user, "password": password} log.error('Please define a settings.yaml file, or include a url if using ' @@ -314,7 +316,7 @@ def release_staging_repos(repos, nexus_url=""): log.debug("Sending data: {}".format(data)) request_url = "{}/staging/bulk/promote".format(_nexus.baseurl) log.debug("Request URL: {}".format(request_url)) - response = requests.post(request_url, json=data) + response = requests.post(request_url, json=data, auth=_nexus.auth) if response.status_code != 201: raise requests.HTTPError("Release failed with the following error:" @@ -325,7 +327,7 @@ def release_staging_repos(repos, nexus_url=""): request_url = "{}/staging/bulk/drop".format(_nexus.baseurl) log.debug("Request URL: {}".format(request_url)) - response = requests.post(request_url, json=data) + response = requests.post(request_url, json=data, auth=_nexus.auth) if response.status_code != 201: raise requests.HTTPError("Drop failed with the following error:" -- 2.16.6