diff --git a/nightlies/trigger_pipelines.py b/nightlies/trigger_pipelines.py index 4e1b10be43a3c3ba754816b7cfcd1e30549a6457..aa8619584f7896f42ff5c8a28ccdf26ed12832c6 100755 --- a/nightlies/trigger_pipelines.py +++ b/nightlies/trigger_pipelines.py @@ -91,6 +91,22 @@ class Gitlab(object): pipeline = subprocess.check_output(cmd) return json.loads(pipeline.decode()) + def create_merge_request(self, project_id, source_branch, target_branch, title, + assignee_id='', description='', target_project_id='', + labels='', milestone_id='', remove_source_branch=''): + url = "projects/{}/merge_requests?" + url += "&".join(['source_branch={}', 'target_branch={}', 'title={}']) + url += "&".join(['assignee_id={}', 'description={}', 'target_project_id={}', + 'labels={}', 'milestone_id={}', 'remove_source_branch={}']) + url = url.format(project_id, source_branch, target_branch, title, + assignee_id, description, target_project_id, labels, + milestone_id, remove_source_branch) + cmd = ["curl", "--request", "POST", "--header", + "PRIVATE-TOKEN: {}".format(self.token), + self.base_url + url] + pipeline = subprocess.check_output(cmd) + return json.loads(pipeline.decode()) + def main(packages_list): gitlab = Gitlab(os.environ.get('GITLAB_API_TOKEN'))