diff --git a/artifactory.py b/artifactory.py index 8176a52..ad236bf 100755 --- a/artifactory.py +++ b/artifactory.py @@ -707,6 +707,7 @@ def rest_post( verify=True, cert=None, timeout=None, + json_data=None, ): """ Perform a POST request to url with requests.session @@ -714,6 +715,7 @@ def rest_post( url = quote_url(url) response = session.post( url, + json=json_data, params=params, headers=headers, verify=verify, @@ -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, @@ -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: @@ -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,