def github_event(): params = getvalues() event = request.headers.get("X-GITHUB-EVENT", "push") hook_signature = request.headers.get("X-Hub-Signature", None) allowed_events = [] if hook_signature: verify_signature(request.data, hook_signature) if BUILD_PULL_REQUEST == "true": allowed_events.append("pull_request") if ((BUILD_PUSH == "true") or (event == "push" and (params['ref'] == "refs/heads/master" or str.startswith(params['ref'], "refs/tags/")))): allowed_events.append("push") if ((event not in allowed_events) or (event == "pull_request" and params['action'] not in ['opened', 'reopened', 'synchronize'])): return jsonify({'ignored': True}) headers = dict(request.headers.to_list()) task = tasks.pipeline.s(params, headers) task.link(tasks.update_github_statuses.s()) task.link_error(tasks.update_github_statuses_failure.s(params, headers)) job = task.delay() return jsonify({'job_id': job.id, 'params': params})
def github_statuses(): params = getvalues() # gitlab_project_id = params['gitlab_project_id'] # gitlab_build_id = params['build_id'] # github_repo = params['github_repo'] # sha = params['sha'] # installation_id = params['installation_id'] delay = int(params.get('delay', 0)) job = tasks.update_github_statuses.apply_async((params, ), countdown=delay) return jsonify({'job_id': job.id, 'params': params})
def github_event(): params = getvalues() hook_signature = request.headers.get("X-Hub-Signature", None) if hook_signature: verify_signature(request.data, hook_signature) headers = dict(request.headers.to_list()) task = tasks.start_pipeline(params, headers) if task is None: return jsonify({'ignored': True}) job = task.delay() return jsonify({'job_id': job.id, 'params': params})
def gitlab_event(): params = getvalues() headers = dict(request.headers.to_list()) event = headers.get("X-Gitlab-Event", None) if event in "Pipeline Hook": task = tasks.update_github_check elif event == "Job Hook": task = tasks.update_github_check else: return jsonify({'ignored': True, 'event': event, 'headers': headers}) job = task.delay(params) return jsonify({'job_id': job.id, 'params': params})
def github_event(): params = getvalues() hook_signature = request.headers.get("X-Hub-Signature", None) if hook_signature: verify_signature(request.data, hook_signature) headers = dict(request.headers.to_list()) gevent = GithubEvent(params, headers) if gevent.event_type == "check_run" and gevent.action == "rerequested": job = tasks.retry_build.delay(gevent.external_id, gevent.head_sha) elif gevent.event_type == "check_run" and gevent.action == "requested_action": job = tasks.request_action( gevent.event['requested_action']['identifier'], params).delay() elif gevent.event_type == "check_suite" and gevent.action == "rerequested": job = tasks.retry_pipeline.delay() elif gevent.event_type in ["push", "pull_request"]: job = tasks.start_pipeline(params, headers).delay() else: return jsonify({'ignored': True, 'event': params, 'headers': headers}) return jsonify({'job_id': job.id, 'params': params})
def gitlab_event(): params = getvalues() return jsonify({'params': params})