Class: RoboPigeon::Dsl::GitLab

Inherits:
GitLabRoot show all
Defined in:
lib/robopigeon/gitlab/dsl.rb

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from GitLabRoot

#api_key, #api_url, #branch, #enabled, #pipeline_id, #project

Methods inherited from Base

#method_missing, #respond_to_missing?

Methods inherited from Job

#gitlab, #jenkins, #jira, #slack

Methods included from Helpers

#skip

Methods included from Helpers::Markdown

#confluence_from_md, #html_from_md, #jira_from_md, #slack_from_md

Methods included from Helpers::GitLab

#deployment_code_change_stats, #deployment_diff_link, #deployment_ref, #deployment_sha, #deployment_shortlog, #deployment_time, #environment_link, #tickets_in_log_since_deployment_to

Methods included from Helpers::Slack

#slack_name_for, #slack_user_for, #slack_user_group

Methods included from Helpers::Jira

#jira_last_created_ticket, #jira_last_created_ticket_link, #jira_last_created_ticket_slack_link, #jira_slack_link

Methods included from Helpers::Git

#changed_since?, #git_branch_merged_source, #git_branch_merged_target, #git_committer_email, #git_committer_name, #git_merger_email, #git_merger_name

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class RoboPigeon::Dsl::Base

Instance Attribute Details

#merge_requestObject

Returns the value of attribute merge_request.



78
79
80
# File 'lib/robopigeon/gitlab/dsl.rb', line 78

def merge_request
  @merge_request
end

Class Method Details

.run(&block) ⇒ Object



80
81
82
83
84
85
86
87
# File 'lib/robopigeon/gitlab/dsl.rb', line 80

def self.run(&block)
  if RoboPigeon::GitLab::Client.enabled
    gitlab = RoboPigeon::Dsl::GitLab.new
    gitlab.instance_eval(&block)
  else
    puts 'Gitlab is disabled, please remove `enabled false` from your global gitlab config'
  end
end

Instance Method Details

#commit(&block) ⇒ Object



174
175
176
# File 'lib/robopigeon/gitlab/dsl.rb', line 174

def commit(&block)
  RoboPigeon::GitLab::Commit.run(&block)
end

#create_merge_request(source, target, arg_title = nil) ⇒ Object



112
113
114
115
# File 'lib/robopigeon/gitlab/dsl.rb', line 112

def create_merge_request(source, target, arg_title=nil)
  title = arg_title || "Automated merge request from #{source} to #{target}"
  self.merge_request = RoboPigeon::GitLab::MergeRequest.create!(source, target, title)
end

#find_merge_request(source, target) ⇒ Object



155
156
157
# File 'lib/robopigeon/gitlab/dsl.rb', line 155

def find_merge_request(source, target)
  RoboPigeon::GitLab::MergeRequest.find(source, target)
end

#merge_branches(source, target, arg_title = nil) ⇒ Object



127
128
129
130
# File 'lib/robopigeon/gitlab/dsl.rb', line 127

def merge_branches(source, target, arg_title=nil)
  title = arg_title || "Automated merge request from #{source} to #{target}"
  RoboPigeon::GitLab::MergeRequest.create!(source, target, title).merge!
end

#merge_merge_requestObject



164
165
166
# File 'lib/robopigeon/gitlab/dsl.rb', line 164

def merge_merge_request
  merge_request.merge!
end

#merge_request_comment(text, source_branch = RoboPigeon::GitLab::Client.branch) ⇒ Object



98
99
100
# File 'lib/robopigeon/gitlab/dsl.rb', line 98

def merge_request_comment(text, source_branch = RoboPigeon::GitLab::Client.branch)
  RoboPigeon::GitLab::Client.merge_request_comment(text, source_branch)
end

#tag(tag, ref = , message = "RoboPigeon tagged at #{Time.now}") ⇒ Object



142
143
144
# File 'lib/robopigeon/gitlab/dsl.rb', line 142

def tag(tag, ref=ENV['CI_COMMIT_REF_NAME'], message="RoboPigeon tagged at #{Time.now}")
  RoboPigeon::GitLab::Client.create_tag(ref, tag, message)
end