Esempio n. 1
0
def rebuild_pr(request, owner, project, pr):
    project_ = Project.objects.filter(owner=owner, name=project).all()[0]
    # Intentionally asking GitHub for the PR
    pull_request = project_.get_pull_request(request.user, int(pr))
    build = JenkinsBuild.new_from_project_pr(project_, pull_request)
    build.trigger_jenkins()
    return HttpResponse(status=204, content_type='application/json')
Esempio n. 2
0
def github(request):
    data = json.loads(request.body)
    action = data['action']
    pull_request = data['pull_request']
    pr_number = int(pull_request["number"])
    project_name = pull_request['base']['repo']['full_name']
    logger.info('Received event from GitHub: PR #{0}, {1}: {2}'.format(
        pr_number, project_name, action))

    html_url = pull_request['html_url']
    pr = PullRequest.update_pull_request(pr_number, project_name, html_url)
    if pr is None:
        return HttpResponse(status=404)

    if action not in ('opened', 'synchronize'):
        return HttpResponse(status=204)

    build = JenkinsBuild.new_from_project_pr(pr.project, pr)
    build.trigger_jenkins()
    build.notify_github()

    return HttpResponse(status=204)