Class: Lita::Handlers::Gitlab2jenkinsGhp

Inherits:
Handler
  • Object
show all
Defined in:
lib/lita/handlers/gitlab2jenkins_ghp.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.default_config(config) ⇒ Object



4
5
6
7
8
9
10
11
12
# File 'lib/lita/handlers/gitlab2jenkins_ghp.rb', line 4

def self.default_config(config)
  config.room                  = '#test2'
  config.group                 = 'group_name'
  config.gitlab_url            = 'http://example.gitlab'
  config.private_token         = 'orwejnweuf'
  config.jenkins_url           = 'http://example.jenkins'
  config.jenkins_hook          = '/gitlab/build'
  config.saved_request         = ''
end

Instance Method Details

#do_ci_change_status(request, response) ⇒ Object



44
45
46
47
48
49
50
51
52
53
54
55
56
57
# File 'lib/lita/handlers/gitlab2jenkins_ghp.rb', line 44

def do_ci_change_status(request, response)
  Lita.logger.info "GitLab CI Project ID: #{request.env['router.params'][:id_project]}"
  Lita.logger.info "GitLab CI Commit SHA: #{request.env['router.params'][:sha_commit]}"
  Lita.logger.info "GitLab CI Token: #{request.params['token']}"
  message = format_message_ci(request.env['router.params'][:id_project][0], request.env['router.params'][:sha_commit][0])
  room = Lita.config.handlers.gitlab2jenkins_ghp.room
  target = Source.new(room: room)
  if message.to_s != 'true'
    response['status'] = message
    Lita.logger.info "CI Final Status: #{message.to_s}"
  end
rescue Exception => e
  Lita.logger.error "Could not domr_change_status: #{e.inspect}"
end

#do_img_jenkins(request, response) ⇒ Object



59
60
61
62
63
64
65
66
67
68
# File 'lib/lita/handlers/gitlab2jenkins_ghp.rb', line 59

def do_img_jenkins(request, response)
  project_name = git_lab_data_project_info(request.env['router.params'][:id_project][0])['name']

  gkeys = @redis.keys("mr:#{project_name}:*")

  code_climate('QA-API', response)

rescue Exception => e
  Lita.logger.error "Could not do_img_jenkins: #{e.inspect}"
end

#do_mr(request, response) ⇒ Object



22
23
24
25
26
27
28
29
30
# File 'lib/lita/handlers/gitlab2jenkins_ghp.rb', line 22

def do_mr(request, response)
  json_body = extract_json_from_request(request)
  Lita.logger.info("Payload: #{json_body}")
  data = symbolize parse_payload(json_body)
  message = format_message(data, json_body)

rescue Exception => e
  Lita.logger.error "Could not domr: #{e.inspect}"
end

#do_mr_change_status(request, response) ⇒ Object



32
33
34
35
36
37
38
39
40
41
42
# File 'lib/lita/handlers/gitlab2jenkins_ghp.rb', line 32

def do_mr_change_status(request, response)
  json_body = extract_json_from_request(request)
  id_project = request.params['id_project'].to_s
  Lita.logger.info "Jenkins Proyect: #{id_project}"
  Lita.logger.info("Payload: #{json_body}")
  data = symbolize parse_payload(json_body)
  message = format_message_mr(data, json_body, id_project)

rescue Exception => e
  Lita.logger.error "Could not domr_change_status: #{e.inspect}"
end