From: Eric Ball Date: Fri, 2 Aug 2019 21:08:06 +0000 (-0700) Subject: Include auth credentials with release requests X-Git-Tag: v0.25.3^0 X-Git-Url: https://gerrit.linuxfoundation.org/infra/gitweb?a=commitdiff_plain;h=refs%2Fchanges%2F23%2F16423%2F1;p=releng%2Flftools.git 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 --- 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:"