soto 0.1.0

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.
Files changed (6) hide show
  1. checksums.yaml +7 -0
  2. data/bin/soto +22 -0
  3. data/lib/commands.rb +24 -0
  4. data/lib/soto.rb +38 -0
  5. data/lib/version.rb +3 -0
  6. metadata +91 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: a03c48409de521174ca0ac3d22dac4ca8e9ed479
4
+ data.tar.gz: 1954be116dd2302bfb8ab260de58a7d31070a07c
5
+ SHA512:
6
+ metadata.gz: 80aac6bdb5fbb335de00b113641702761516c6237fadc278ae46205f79df6d118a30c6414879c7e8492050beb6a2b352dc115115d05201ca2d7dc239505f5d75
7
+ data.tar.gz: 0762c11dcbaad38365bac2bc6478b465e818e5a7edeeb563171c9525e36d3c5503f1d6b910b290ef20cea9a378db350a640986de042dc3e389e8427d822d12fb
data/bin/soto ADDED
@@ -0,0 +1,22 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'commander/import'
4
+
5
+ require 'terminal-table'
6
+
7
+ $:.push File.expand_path('../../lib', __FILE__)
8
+
9
+ require 'soto'
10
+ require 'version'
11
+
12
+ HighLine.track_eof = false
13
+
14
+ program :version, Soto::VERSION
15
+ program :description, 'Read revision version of last successful TeamCity build for your project'
16
+
17
+ program :help, 'Author', 'Michał Łukasiewicz <michal.lukasiewicz@gmail.com>'
18
+ program :help, 'Website', 'http://brightinventions.pl'
19
+
20
+ default_command :help
21
+
22
+ require 'commands.rb'
data/lib/commands.rb ADDED
@@ -0,0 +1,24 @@
1
+ require 'soto'
2
+
3
+ command :read do |c|
4
+ c.syntax = 'soto read -u username -p password -t teamcity_url -b build_configuration'
5
+ c.summary = 'Read revision version of last successful TeamCity build specified build'
6
+ c.description = 'Read revision version of last successful TeamCity build specified build'
7
+
8
+ c.option '-u', '--username USERNAME', 'TeamCity username'
9
+ c.option '-p', '--password PASSWORD', 'TeamCity password'
10
+ c.option '-c', '--teamcity_url TEAMCITY_URL', 'TeamCity url'
11
+ c.option '-b', '--build_configuration BUILD_CONFIGURATION', 'Build configuration'
12
+
13
+ c.action do |args, options|
14
+
15
+ say_error 'Missing TeamCity username' and abort unless options.username
16
+ say_error 'Missing TeamCity password' and abort unless options.password
17
+ say_error 'Missing TeamCity url' and abort unless options.teamcity_url
18
+ say_error 'Missing build configuration' and abort unless options.build_configuration
19
+
20
+ Soto::Soto.read(options.username, options.password, options.teamcity_url, options.build_configuration)
21
+
22
+ end
23
+
24
+ end
data/lib/soto.rb ADDED
@@ -0,0 +1,38 @@
1
+ require 'nokogiri'
2
+ require 'net/http'
3
+
4
+ module Soto
5
+ class Soto
6
+ def self.read(username, password, teamcity_url, build_configuration)
7
+
8
+ path = "#{teamcity_url}/app/rest/buildTypes/id:#{build_configuration}/builds/status:SUCCESS"
9
+
10
+ uri = URI(path)
11
+
12
+ req = Net::HTTP::Get.new(path)
13
+ req.basic_auth username, password
14
+
15
+ Net::HTTP.start(uri.host, uri.port) { |http|
16
+ resp = http.request(req)
17
+
18
+ if resp.code != '200'
19
+ STDERR.puts "#{resp.message} (#{resp.code})"
20
+ exit -1
21
+ end
22
+
23
+ dom = Nokogiri::XML(resp.body)
24
+ revision_version = dom.xpath('//revisions/revision[1]/@version')
25
+
26
+ if revision_version.empty?
27
+ STDERR.puts 'No revision found'
28
+ STDERR.puts 'Response from server:'
29
+ STDERR.puts resp.body
30
+ exit -1
31
+ end
32
+
33
+ puts revision_version
34
+ }
35
+
36
+ end
37
+ end
38
+ end
data/lib/version.rb ADDED
@@ -0,0 +1,3 @@
1
+ module Soto
2
+ VERSION = '0.1.0'
3
+ end
metadata ADDED
@@ -0,0 +1,91 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: soto
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.0
5
+ platform: ruby
6
+ authors:
7
+ - Michał Łukasiewicz
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: commander
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '4.3'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '4.3'
27
+ - !ruby/object:Gem::Dependency
28
+ name: highline
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: 1.7.1
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: 1.7.1
41
+ - !ruby/object:Gem::Dependency
42
+ name: nokogiri
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.6'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.6'
55
+ description: Soto connects to TeamCity REST API and extracts revision number for last
56
+ successful TeamCity build
57
+ email: michal.lukasiewicz@gmail.com
58
+ executables:
59
+ - soto
60
+ extensions: []
61
+ extra_rdoc_files: []
62
+ files:
63
+ - bin/soto
64
+ - lib/commands.rb
65
+ - lib/soto.rb
66
+ - lib/version.rb
67
+ homepage: http://brightinventions.pl
68
+ licenses:
69
+ - MIT
70
+ metadata: {}
71
+ post_install_message:
72
+ rdoc_options: []
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ requirements:
77
+ - - ">="
78
+ - !ruby/object:Gem::Version
79
+ version: '0'
80
+ required_rubygems_version: !ruby/object:Gem::Requirement
81
+ requirements:
82
+ - - ">="
83
+ - !ruby/object:Gem::Version
84
+ version: '0'
85
+ requirements: []
86
+ rubyforge_project:
87
+ rubygems_version: 2.4.6
88
+ signing_key:
89
+ specification_version: 4
90
+ summary: Extract revision number of last successful TeamCity build
91
+ test_files: []