Class: Bumper
- Inherits:
-
Object
- Object
- Bumper
- Defined in:
- lib/bumper.rb
Constant Summary collapse
- VERSION =
"0.1.3"
Class Method Summary collapse
- .create_merge_request_from_submodule(submodule_name, git, from_project_id, to_project_id, gitlab_key, gitlab_url = 'http://src.sibext.com/api/v3') ⇒ Object
- .jenkins_build_number(job_name) ⇒ Object
- .submodule_update_version(display, name, git) ⇒ Object
- .tag(git_path, tag_name) ⇒ Object
Class Method Details
.create_merge_request_from_submodule(submodule_name, git, from_project_id, to_project_id, gitlab_key, gitlab_url = 'http://src.sibext.com/api/v3') ⇒ Object
43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/bumper.rb', line 43 def self.create_merge_request_from_submodule submodule_name, git, from_project_id, to_project_id, gitlab_key, gitlab_url='http://src.sibext.com/api/v3' Gitlab.endpoint=gitlab_url Gitlab.private_token=gitlab_key begin opened = Gitlab.merge_requests(from_project_id).select{ |m| m.state == "opened"} merge = opened.sort { |a,b| a.created_at <=> b.created_at }.last rescue Gitlab::Error::NotFound => e merge = nil end if merge submodule_update_feature submodule_name, git, merge.source_branch Gitlab.create_merge_request to_project_id, "[AUTO] #{merge.title}", source_branch: merge.source_branch, target_branch: 'master', description: merge.description end end |
.jenkins_build_number(job_name) ⇒ Object
18 19 20 21 22 23 24 25 26 |
# File 'lib/bumper.rb', line 18 def self.jenkins_build_number job_name @client = JenkinsApi::Client.new YAML.load_file(File.("../config/jenkins.yml", __FILE__)) @client.logger = Logger.new('jenkins_build_number.log', 10, 1024000) begin number = @client.job.get_current_build_number(job_name) rescue JenkinsApi::Exceptions::NotFound => e end number end |
.submodule_update_version(display, name, git) ⇒ Object
28 29 30 31 32 33 34 35 36 37 38 39 40 41 |
# File 'lib/bumper.rb', line 28 def self.submodule_update_version display, name, git project_path = 'git_with_submodule' bumper_ssh do |w| w.set_env `rm -Rf #{project_path}` `git clone --recursive #{git} #{project_path}` `#{git(project_path)} checkout -b UpdateFrom#{display}` `cd #{project_path} && git submodule update --remote #{name}` `#{git(project_path)} commit -am'New updates from #{display}'` `#{git(project_path)} push --force origin UpdateFrom#{display}` `#{git(project_path)} checkout master` `#{git(project_path)} branch -D UpdateFrom#{display}` end end |
.tag(git_path, tag_name) ⇒ Object
10 11 12 13 14 15 16 |
# File 'lib/bumper.rb', line 10 def self.tag git_path, tag_name bumper_ssh do |w| w.set_env `#{git(git_path)} tag '-f' '#{tag_name}' '-m tagged by Bumber'` `#{git(git_path)} push '--force' 'origin' 'refs/tags/#{tag_name}'` end end |