@csrf_exempt
def gitlab_build(request):
 if (request.method == 'POST'):
  try:
   data = json.loads(request.body)
   url = data['project']['http_url']
   search_url = re.sub('^https?://(.*?)(?:\\.git|)$', '\\1', url)
   branches = [data['ref'].replace('refs/heads/', '')]
  except (ValueError, TypeError, KeyError):
   log.error('Invalid GitLab webhook payload', exc_info=True)
   return HttpResponse('Invalid request', status=400)
  log.info('GitLab webhook search: url=%s branches=%s', search_url, branches)
  projects = get_project_from_url(search_url)
  if projects:
   return _build_url(search_url, projects, branches)
  else:
   log.error('Project match not found: url=%s', search_url)
   return HttpResponseNotFound('Project match not found')
 else:
  return HttpResponse('Method not allowed, POST is required', status=405)

@ csrf_exempt def gitlab_build ( request ) : if ( request . method == 'POST' ) : try : data = json . loads ( request . body ) url = data [ 'project' ] [ 'http_url' ] search_url = re . sub ( '^https?://(.*?)(?:\\.git|)$' , '\\1' , url ) branches = [ data [ 'ref' ] . replace ( 'refs/heads/' , '' ) ] except ( ValueError , TypeError , KeyError ) : log . error ( 'Invalid GitLab webhook payload' , exc_info = True ) return HttpResponse ( 'Invalid request' , status = 400 ) log . info ( 'GitLab webhook search: url=%s branches=%s' , search_url , branches ) projects = get_project_from_url ( search_url ) if projects : return _build_url ( search_url , projects , branches ) else : log . error ( 'Project match not found: url=%s' , search_url ) return HttpResponseNotFound ( 'Project match not found' ) else : return HttpResponse ( 'Method not allowed, POST is required' , status = 405 )
gitlab webhook consumer search project repository urls using the site url from gitlab webhook payload .