bumperok 0.0.2 → 0.0.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 3b6b5a4d992277a63a651fa6d067a29f7f83b85d
4
- data.tar.gz: 862b74573de4c30ac673afb3ddb07714bf9b0a34
3
+ metadata.gz: af6cce691f8bbb11bb6223153036ce906064cbfe
4
+ data.tar.gz: fd99cf9b4a93c5815f179d0ff176c9def9264f25
5
5
  SHA512:
6
- metadata.gz: 08ee373258321134ebb38f3b97c9a187bc6e0771f593dd1387fdf5d2bc457d987c897b91bfcd03fdff16954bd1fb3df24013ba3e4bd1632992853deec40720ed
7
- data.tar.gz: 45014e79c7ba94328f522e50a12a4cee4f94508fda3d2d2aa3d140df25259257e9f72aae190a690b3cfdf50b817131fa5b1bd91383b0cdc454c7c95404926107
6
+ metadata.gz: 4262d79427ebe11ac83178ad34a39085d7bf9a11a7aaa951cbb2be26feae421b894b55d1dba0670049737d3ae223d5e3ae263a94265aa24780cbbe6daf7aaf59
7
+ data.tar.gz: 1353a73524664b47014b83dcc740baec91bdd11a5a089ca100a140d07eb907b13a5671c8419b4cdb357d328e73a7318a764ce7cc83a21f30a040ed17a56e6201
data/Manifest.txt CHANGED
@@ -6,3 +6,4 @@ Rakefile
6
6
  bin/bumper
7
7
  lib/bumper.rb
8
8
  test/test_bumper.rb
9
+ config/jenkins.yml
data/Rakefile CHANGED
@@ -16,6 +16,7 @@ Hoe.spec "bumperok" do
16
16
  license "MIT"
17
17
  dependency 'git', '~> 1.2'
18
18
  dependency 'git-ssh-wrapper', '~> 0.2'
19
+ dependency 'jenkins_api_client', '~> 0.2'
19
20
  end
20
21
 
21
22
  # vim: syntax=ruby
data/bin/bumper CHANGED
@@ -21,14 +21,35 @@ OptionParser.new do |opts|
21
21
  options.git_path = g
22
22
  end
23
23
 
24
+ opts.on("-pPROJECT", "--project-name=PROJECT", "Project name for jenkins prefix") do |p|
25
+ options.project_name = p
26
+ end
27
+
28
+ opts.on("-sGIT_URL", "--git-url=GIT_URL", "Access url to git server") do |g|
29
+ options.git_url = g
30
+ end
31
+
32
+ opts.on("-mSUBMODULE", "--git-submodule=SUBMODULE", "The name of git submodule") do |m|
33
+ options.git_submodule = m
34
+ end
35
+
24
36
  end.parse!
25
37
 
26
- if options.cmd and options.cmd == 'tag'
38
+ case options.cmd
39
+ when 'tag'
27
40
  if options.tag and options.git_path
28
41
  Bumper.tag options.git_path, options.tag
29
42
  else
30
43
  p "Bad options"
31
44
  end
32
- else
45
+ when 'build'
46
+ if options.project_name
47
+ print Bumper.jenkins_build_number(options.project_name)
48
+ end
49
+ when 'submodule'
50
+ if options.git_url and options.git_submodule
51
+ Bumper.submodule_update_version(options.git_submodule, options.git_submodule, options.git_url)
52
+ end
53
+ eelse
33
54
  raise "#{options.cmd} is unsupported command"
34
55
  end
@@ -0,0 +1,27 @@
1
+ # The Jenkins server and login information can be stored in a YAML file like this
2
+ # so we don't have to pass in the parameters every we login to the server
3
+ # through this API client.
4
+
5
+ # This file contains the following four parameters
6
+
7
+ # The IP address of the Jenkins CI Server
8
+
9
+ :server_ip: 0.0.0.0
10
+
11
+ # The port number on which the Jenkins listens on. The default is 8080
12
+
13
+ :server_port: 8080
14
+
15
+ # If there is a web server routing your Jenkins requests you might need this
16
+
17
+ :jenkins_path: ""
18
+
19
+ # The username and password to authenticate to the server
20
+
21
+ :username: my_username
22
+
23
+ :password: my_password
24
+
25
+ # The private key file for Jenkins CLI authentication
26
+ # remember to upload the public key to http://#{server_ip}:#{server_port}/user/#{my_username}/configure
27
+ :identity_file: ~/.ssh/id_rsa
data/lib/bumper.rb CHANGED
@@ -1,9 +1,10 @@
1
1
  require 'git'
2
2
  require 'logger'
3
3
  require 'git-ssh-wrapper'
4
+ require 'jenkins_api_client'
4
5
 
5
6
  class Bumper
6
- VERSION = "0.0.2"
7
+ VERSION = "0.0.3"
7
8
 
8
9
  def self.tag git_path, tag_name
9
10
  wrapper = GitSSHWrapper.with_wrapper(private_key_path: '~/.ssh/bumber_at_sibext', log_level: 'ERROR') do |w|
@@ -12,5 +13,27 @@ class Bumper
12
13
  `git '--git-dir=#{git_path}/.git' '--work-tree=#{git_path}' push '--force' 'origin' 'refs/tags/#{tag_name}'`
13
14
  end
14
15
  end
16
+
17
+ def self.jenkins_build_number job_name
18
+ @client = JenkinsApi::Client.new YAML.load_file(File.expand_path("../config/jenkins.yml", __FILE__))
19
+ @client.logger = Logger.new('jenkins_build_number.log', 10, 1024000)
20
+ begin
21
+ number = @client.job.get_current_build_number(job_name)
22
+ rescue JenkinsApi::Exceptions::NotFound => e
23
+ end
24
+ number
25
+ end
26
+
27
+ def self.submodule_update_version display, name, git
28
+ wrapper = GitSSHWrapper.with_wrapper(private_key_path: '~/.ssh/bumber_at_sibext', log_level: 'ERROR') do |w|
29
+ w.set_env
30
+ `rm -Rf git_with_submodule`
31
+ `git clone --recursive #{git} git_with_submodule`
32
+ `git submodule update --remote #{name}`
33
+ `git checkout -b UpdateFrom#{display}`
34
+ `git commit -am'New updates from #{display}'`
35
+ `git push -f origin UpdateFrom#{display}`
36
+ end
15
37
 
38
+ end
16
39
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bumperok
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.2
4
+ version: 0.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nikolay Moskvin
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: git
@@ -38,6 +38,20 @@ dependencies:
38
38
  - - "~>"
39
39
  - !ruby/object:Gem::Version
40
40
  version: '0.2'
41
+ - !ruby/object:Gem::Dependency
42
+ name: jenkins_api_client
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.2'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.2'
41
55
  - !ruby/object:Gem::Dependency
42
56
  name: rdoc
43
57
  requirement: !ruby/object:Gem::Requirement
@@ -86,6 +100,7 @@ files:
86
100
  - README.txt
87
101
  - Rakefile
88
102
  - bin/bumper
103
+ - config/jenkins.yml
89
104
  - lib/bumper.rb
90
105
  - test/test_bumper.rb
91
106
  homepage: http://git.sibext.com/snacks/bumper