Module: GitlabTools

Defined in:
lib/citasks/ci_lib.rb

Class Method Summary collapse

Class Method Details

._setup_gitlab(gitlab_url, token) ⇒ Object



180
181
182
183
# File 'lib/citasks/ci_lib.rb', line 180

def self._setup_gitlab gitlab_url, token
  Gitlab.endpoint = "#{gitlab_url}/api/v4"
  Gitlab.private_token = token
end

.delete!(repo_name, gitlab_url, token) ⇒ Object



203
204
205
206
207
208
209
210
211
212
213
214
215
# File 'lib/citasks/ci_lib.rb', line 203

def self.delete! repo_name, gitlab_url, token
  _setup_gitlab gitlab_url, token

  project = Gitlab.projects.find do |p|
    p.name== repo_name
  end
  if project.nil?
    puts "repo #{repo_name} doesn't exists" 
    return
  end

  Gitlab.delete_project project.id
end

.new_repo(repo_name, gitlab_url, token) ⇒ Object



185
186
187
188
# File 'lib/citasks/ci_lib.rb', line 185

def self.new_repo repo_name, gitlab_url, token
  _setup_gitlab gitlab_url, token
  Gitlab.create_project repo_name
end

.setup_hook(repo_name, gitlab_url, token, hooked_url, secret_token = nil) ⇒ Object



190
191
192
193
194
195
196
197
198
199
200
201
# File 'lib/citasks/ci_lib.rb', line 190

def self.setup_hook repo_name, gitlab_url, token, hooked_url, secret_token=nil
  _setup_gitlab gitlab_url, token

  project = Gitlab.projects.find do |p|
    p.name== repo_name
  end

  secret_token = token_shared_persistently if secret_token.nil?
  
  Gitlab.add_project_hook project.id, hooked_url, :push_events => 1,:enable_ssl_verification=>0, :token=> secret_token

end