WTBuildHelpers 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 899f3d4ed4d147d9310a7327e55318e6ec88bc38
4
- data.tar.gz: 3eae7c5fe00913c91c507972610b0166845a4d46
3
+ metadata.gz: 519d193004401b8d48552f7cc559d8131fa50cda
4
+ data.tar.gz: c9b7f36e48cf80bebf5d6054aac6b789c6af83f2
5
5
  SHA512:
6
- metadata.gz: aec03ba6b56605356742fe8d81c2f322016b63860202e7e8d1b4b5a230a2de855d63263c8c02da24cbb9aff925c88fca07938f32ef448211738eefc6602d9650
7
- data.tar.gz: 2f2212b2a1c62cc090d51ac58c95a82c972ee3ccb44636a8e4ed212b8cf5d863cbbc78767aac4b679cf679f82143930eed2c3156b7da9075ecaf1a292c2e3c11
6
+ metadata.gz: d81872eda9376b67314cfba5d5d8d922e2df9e9a933c0be760cdbae455a23472d109043d1a25d11236dada6c27ebb2f62377cb4b6ce054dd0691104f3c5af719
7
+ data.tar.gz: aae17905af803370f9dd4d6f569afd85b51810ae0bb8f89248a7bdf4a463e5e4ca9e5f21a6b2fe4812258bc20ab73cc8639deee1352cd8bb21b50d615f51d3ce
@@ -1,3 +1,3 @@
1
1
  module WTBuildHelpers
2
- VERSION = "0.1.0"
2
+ VERSION = "0.1.1"
3
3
  end
@@ -6,35 +6,41 @@ require 'rest_client'
6
6
  require 'pp'
7
7
 
8
8
  module WTBuildHelpers
9
- module TeamCity
10
- def self.fetch_commit_range(teamcity_url, build_type_id, username, password)
11
-
12
- auth_token = Base64.encode64("#{username}:#{password}")
13
- headers = { "Authorization" => "Basic #{auth_token}",
14
- "Accept" => "application/json"
15
- }
16
-
17
- full_url = "#{teamcity_url}/app/rest/buildTypes/id:#{build_type_id}/builds/status:SUCCESS"
18
-
19
- response = RestClient.get(full_url, headers=headers)
20
- json_response = JSON.parse(response.body)
21
-
22
- start_revision = ENV["BUILD_VCS_NUMBER"]
23
- end_revision = json_response["revisions"]["revision"][0]["version"]
24
-
25
- puts "##teamcity[setParameter name='env.TEAMCITY_COMMIT_RANGE' value='#{start_revision}..#{end_revision}']"
26
- end
27
- end
9
+ module TeamCity
10
+ def self.fetch_commit_range(teamcity_url, build_type_id, username, password)
11
+
12
+ auth = "#{username}:#{password}"
13
+ auth_token = Base64.strict_encode64(auth)
14
+
15
+ headers = { "Authorization" => "Basic #{auth_token}",
16
+ "Accept" => "application/json"
17
+ }
18
+ full_url = "#{teamcity_url}/app/rest/buildTypes/id:#{build_type_id}/builds/status:SUCCESS"
19
+
20
+ begin
21
+ response = RestClient.get(full_url, headers=headers)
22
+ json_response = JSON.parse(response.body)
23
+ rescue RestClient::Exception => e
24
+ pp e
25
+ exit
26
+ end
27
+
28
+ start_revision = ENV["BUILD_VCS_NUMBER"]
29
+ end_revision = json_response["revisions"]["revision"][0]["version"]
30
+
31
+ puts "##teamcity[setParameter name='env.TEAMCITY_COMMIT_RANGE' value='#{start_revision}..#{end_revision}']"
32
+ end
33
+ end
28
34
  end
29
35
 
30
36
  if __FILE__ == $0
31
- if ARGV.length < 4
32
- puts "Usage: teamcity_git_range_fetch.rb [TeamCity Url] [TeamCity Build Type Id] [TeamCity User Name] [TeamCity Password]"
33
- puts "These parameters can be passed from TeamCity with the following line: "
34
- puts " teamcity_git_range_fetch.rb \"%teamcity.serverUrl%\" \"%system.teamcity.buildType.id%\" \"%system.teamcity.auth.userId%\" \"%system.teamcity.auth.password%\""
35
-
36
- exit
37
- end
38
-
39
- WTBuildHelpers::TeamCity.fetch_commit_range(ARGV[0], ARGV[1], ARGV[2], ARGV[3])
37
+ if ARGV.length < 4
38
+ puts "Usage: teamcity_git_range_fetch.rb [TeamCity Url] [TeamCity Build Type Id] [TeamCity User Name] [TeamCity Password]"
39
+ puts "These parameters can be passed from TeamCity with the following line: "
40
+ puts " teamcity_git_range_fetch.rb \"%teamcity.serverUrl%\" \"%system.teamcity.buildType.id%\" \"%system.teamcity.auth.userId%\" \"%system.teamcity.auth.password%\""
41
+
42
+ exit
43
+ end
44
+
45
+ WTBuildHelpers::TeamCity.fetch_commit_range(ARGV[0], ARGV[1], ARGV[2], ARGV[3])
40
46
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: WTBuildHelpers
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0
4
+ version: 0.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - WillowTreeApps
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2015-11-05 00:00:00.000000000 Z
11
+ date: 2015-11-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: OptionParser