WTBuildHelpers 0.2.2 → 0.2.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/README.md +2 -2
- data/lib/WTBuildHelpers/version.rb +1 -1
- data/lib/jira.rb +10 -6
- data/lib/teamcity.rb +7 -7
- data/lib/teamcity_git_range_fetch.rb +46 -0
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4cb2d1b4ccc6ea6717cf0e2e00ad2c71da93fa6
|
4
|
+
data.tar.gz: 5a8f9e8efc904d320f4a82ad01997cb7bcacf9e4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c3ccced0bb074d3097ce5afbd86fc4c5576d12d4b410be3ac33418d76008ce89704075148ebcfedd523d9cdc96d1865bf08eddf75e01a5f8f5a64ba98cbf4a12
|
7
|
+
data.tar.gz: e944cac46b9fd0ec8160575abfcd013aa0572f011978c3129bf0b983d3393b4289614de73f4017478d7d87cd76375c1d4a5a8c2d072123e660a84d85051aafcf
|
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -38,7 +38,7 @@ $ wtbuild teamcity_fetch_git_range --url "%teamcity.serverUrl%" --build_type "%s
|
|
38
38
|
|
39
39
|
Command Line Usage (when run as part of a larger build step):
|
40
40
|
```bash
|
41
|
-
$ export TEAMCITY_COMMIT_RANGE
|
41
|
+
$ export TEAMCITY_COMMIT_RANGE=`wtbuild teamcity_fetch_git_range --url "%teamcity.serverUrl%" --build_type "%system.teamcity.buildType.id%" --username "%system.teamcity.auth.userId%" --password "%system.teamcity.auth.password%" --export`
|
42
42
|
```
|
43
43
|
|
44
44
|
## Installation
|
@@ -63,4 +63,4 @@ Or install it yourself as:
|
|
63
63
|
|
64
64
|
## Development
|
65
65
|
|
66
|
-
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
66
|
+
After checking out the repo, run `bin/setup` to install dependencies. Then, run `bin/console` for an interactive prompt that will allow you to experiment.
|
data/lib/jira.rb
CHANGED
@@ -115,7 +115,7 @@ module WTBuildHelpers::JIRA
|
|
115
115
|
def self.find_jira_issues(logs)
|
116
116
|
issue_set = Set.new
|
117
117
|
logs.each do |log|
|
118
|
-
issues = log.scan(/[A-
|
118
|
+
issues = log.scan(/[A-Za-z][A-Za-z]+-[1-9][0-9]*/)
|
119
119
|
issue_set.merge(issues)
|
120
120
|
end
|
121
121
|
|
@@ -125,8 +125,10 @@ module WTBuildHelpers::JIRA
|
|
125
125
|
def self.get_git_history(commit_range)
|
126
126
|
puts "Getting git history for #{commit_range}"
|
127
127
|
happyface = "\u263A".encode('utf-8')
|
128
|
-
|
129
|
-
|
128
|
+
extra_params = commit_range.index('..') == nil ? "-n 1" : ""
|
129
|
+
git_log = `git --no-pager log --format="%B#{happyface}" #{commit_range} #{extra_params}`
|
130
|
+
puts(git_log)
|
131
|
+
|
130
132
|
#parse out the log
|
131
133
|
logs = git_log.split(happyface)
|
132
134
|
|
@@ -149,7 +151,7 @@ module WTBuildHelpers::JIRA
|
|
149
151
|
|
150
152
|
#still nil? Can't perform this transition
|
151
153
|
if !jira_info.build_complete_transition_id
|
152
|
-
puts "Could
|
154
|
+
puts "Could not update issue #{issue_key}: could not find transition"
|
153
155
|
next
|
154
156
|
end
|
155
157
|
|
@@ -231,8 +233,10 @@ module WTBuildHelpers::JIRA
|
|
231
233
|
logs = get_git_history(options.commit_range)
|
232
234
|
issue_set = find_jira_issues(logs)
|
233
235
|
|
234
|
-
|
235
|
-
|
236
|
+
if issue_set.size > 0
|
237
|
+
jira_info = JiraInfo.new options.site, options.username, options.password
|
238
|
+
jira_update(jira_info, issue_set, options.build)
|
239
|
+
end
|
236
240
|
end
|
237
241
|
end
|
238
242
|
end
|
data/lib/teamcity.rb
CHANGED
@@ -82,7 +82,7 @@ module WTBuildHelpers::TeamCity
|
|
82
82
|
escaped_branch = URI.escape(branch)
|
83
83
|
|
84
84
|
full_url = "#{options.url}/app/rest/buildTypes/id:#{options.build_type_id}/builds/?locator=status:SUCCESS,branch:name:#{escaped_branch}"
|
85
|
-
|
85
|
+
|
86
86
|
response = RestClient.get(full_url, headers=headers)
|
87
87
|
json_response = JSON.parse(response.body)
|
88
88
|
|
@@ -110,13 +110,13 @@ module WTBuildHelpers::TeamCity
|
|
110
110
|
STDERR.puts "Start revision is #{start_revision}"
|
111
111
|
|
112
112
|
begin
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
end_revision = get_last_successful_rev(options,
|
113
|
+
check_branches = [branch, "refs/heads/#{branch}", branch.split("/").last]
|
114
|
+
end_revision = nil
|
115
|
+
while end_revision == nil && check_branches.length > 0 do
|
116
|
+
check_branch = check_branches.shift
|
117
|
+
end_revision = get_last_successful_rev(options, check_branch)
|
118
118
|
end
|
119
|
-
|
119
|
+
|
120
120
|
put_range(options, start_revision, end_revision)
|
121
121
|
rescue RestClient::Exception => e
|
122
122
|
puts "ERROR getting last successful build from TeamCity:"
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
|
3
|
+
require 'base64'
|
4
|
+
require 'json'
|
5
|
+
require 'rest_client'
|
6
|
+
require 'pp'
|
7
|
+
|
8
|
+
module WTBuildHelpers
|
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='#{end_revision}..#{start_revision}']"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
if __FILE__ == $0
|
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])
|
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.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- WillowTreeApps
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2016-06
|
11
|
+
date: 2016-12-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: OptionParser
|
@@ -88,6 +88,7 @@ files:
|
|
88
88
|
- lib/help.rb
|
89
89
|
- lib/jira.rb
|
90
90
|
- lib/teamcity.rb
|
91
|
+
- lib/teamcity_git_range_fetch.rb
|
91
92
|
homepage:
|
92
93
|
licenses:
|
93
94
|
- MIT
|
@@ -108,7 +109,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
108
109
|
version: '0'
|
109
110
|
requirements: []
|
110
111
|
rubyforge_project:
|
111
|
-
rubygems_version: 2.
|
112
|
+
rubygems_version: 2.0.14.1
|
112
113
|
signing_key:
|
113
114
|
specification_version: 4
|
114
115
|
summary: Helpers for performing common WillowTree build tasks and integrations
|