Skip to content

Commit

Permalink
bugfix: make Build Promotion works (#360)
Browse files Browse the repository at this point in the history
* bugfix: make Build Promotion works

fix: #334

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
donhui and pre-commit-ci[bot] authored Aug 8, 2022
1 parent 1ef991a commit 98bf945
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions artifactory.py
Original file line number Diff line number Diff line change
Expand Up @@ -707,13 +707,15 @@ def rest_post(
verify=True,
cert=None,
timeout=None,
json_data=None,
):
"""
Perform a POST request to url with requests.session
"""
url = quote_url(url)
response = session.post(
url,
json=json_data,
params=params,
headers=headers,
verify=verify,
Expand Down Expand Up @@ -2640,13 +2642,15 @@ def promote_build(
:param fail_fast: fail and abort the operation upon receiving an error. Default: true
:return:
"""
url = f"/api/build/promote/{build_name}/{build_number}"
url = f"{self.drive}/api/build/promote/{build_name}/{build_number}"

if not isinstance(properties, dict):
raise ArtifactoryException("properties must be a dict")

iso_time = datetime.datetime.now().astimezone().isoformat()
params = {
iso_time = (
datetime.datetime.now().astimezone().strftime("%Y-%m-%dT%H:%M:%S.%f%z")
)
json_data = {
"status": status,
"comment": comment,
"ciUser": ci_user,
Expand All @@ -2659,10 +2663,10 @@ def promote_build(
"failFast": fail_fast,
}
if source_repo:
params["sourceRepo"] = source_repo
json_data["sourceRepo"] = source_repo

if target_repo:
params["targetRepo"] = target_repo
json_data["targetRepo"] = target_repo

if dependencies:
if not scopes:
Expand All @@ -2673,11 +2677,11 @@ def promote_build(
if not isinstance(scopes, list):
raise ArtifactoryException("scopes must be a list")

params["scopes"] = scopes
json_data["scopes"] = scopes

self.rest_post(
self._accessor.rest_post(
url,
params=params,
json_data=json_data,
session=self.session,
verify=self.verify,
cert=self.cert,
Expand Down

0 comments on commit 98bf945

Please sign in to comment.