Class: Gitlab::QA::Slack::PostToSlack

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/qa/slack/post_to_slack.rb

Instance Method Summary collapse

Constructor Details

#initialize(message:) ⇒ PostToSlack

Returns a new instance of PostToSlack.



5
6
7
# File 'lib/gitlab/qa/slack/post_to_slack.rb', line 5

def initialize(message:)
  @message = message
end

Instance Method Details

#invoke!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'lib/gitlab/qa/slack/post_to_slack.rb', line 9

def invoke!
  Runtime::Env.require_slack_qa_channel!
  Runtime::Env.require_ci_slack_webhook_url!

  params = {}
  params['channel'] = Runtime::Env.slack_qa_channel
  params['username'] = "GitLab QA Bot"
  params['icon_emoji'] = Runtime::Env.slack_icon_emoji
  params['text'] = @message

  url = Runtime::Env.ci_slack_webhook_url

  Support::HttpRequest.make_http_request(method: 'post', url: url, params: params)
end