jira-wsdl 0.0.1 → 0.0.2
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.
- data/README.md +6 -1
- data/Rakefile +11 -1
- data/lib/jira-wsdl.rb +65 -33
- metadata +3 -4
data/README.md
CHANGED
data/Rakefile
CHANGED
data/lib/jira-wsdl.rb
CHANGED
@@ -15,13 +15,15 @@ class JiraWsdl
|
|
15
15
|
#create Savon.client
|
16
16
|
@client = Savon.client(wsdl: @wsdl_url, log: false)
|
17
17
|
|
18
|
-
#operation list permited by JIRA soap
|
19
|
-
#@operations_available = @client.operations.sort
|
20
|
-
|
21
18
|
#create login token
|
22
19
|
@token ||= self.get_token
|
23
20
|
end
|
24
21
|
|
22
|
+
def list_operations
|
23
|
+
#operation list permited by JIRA soap
|
24
|
+
@operations_available = @client.operations.sort
|
25
|
+
end
|
26
|
+
|
25
27
|
#get token login
|
26
28
|
#
|
27
29
|
# @return [String] token
|
@@ -48,49 +50,76 @@ class JiraWsdl
|
|
48
50
|
puts error.to_hash[:fault][:faultstring]
|
49
51
|
end
|
50
52
|
|
51
|
-
#
|
53
|
+
#logout of jira
|
54
|
+
#
|
55
|
+
# @param [String] token
|
56
|
+
# @return [Boolean]
|
57
|
+
def logout(token = @token)
|
58
|
+
response=nil
|
59
|
+
Timeout::timeout(60) {
|
60
|
+
response = @client.call(:logout, message: {:token => token})
|
61
|
+
}
|
62
|
+
response.to_hash[:logout_response][:logout_return]
|
63
|
+
end
|
64
|
+
|
65
|
+
#checks if a project exist
|
66
|
+
#
|
67
|
+
# @param [String] project
|
68
|
+
# @return [Boolean]
|
69
|
+
def check_project project
|
70
|
+
@client.call(:get_project_by_key, message: {:token => @token, :key => project.upcase})
|
71
|
+
true
|
72
|
+
rescue Savon::SOAPFault => error
|
73
|
+
error = error.to_hash[:fault][:faultstring]
|
74
|
+
return false, error
|
75
|
+
end
|
76
|
+
|
77
|
+
#get the actual version and the next version of a project
|
52
78
|
# @param [String] project_name
|
53
79
|
def get_version(project_name)
|
54
80
|
tries ||= 5
|
55
81
|
all_versions = []
|
82
|
+
result, error = (self.check_project project_name)
|
56
83
|
|
57
|
-
|
58
|
-
|
84
|
+
unless result == false
|
85
|
+
#get all versions xml
|
86
|
+
response = @client.call(:get_versions, message: {:token => @token, :key => project_name.upcase})
|
59
87
|
|
60
|
-
|
61
|
-
|
62
|
-
|
88
|
+
#get next version from hash
|
89
|
+
next_version_id = response.to_hash[:get_versions_response][:get_versions_return][:'@soapenc:array_type']
|
90
|
+
next_version_id = next_version_id.match(/RemoteVersion\[(\d+)\]/)[1]
|
63
91
|
|
64
|
-
|
65
|
-
|
92
|
+
#get actual version from the array of version id's
|
93
|
+
actual_version_id = (self.get_all_version_ids response.to_hash).sort.last - 1
|
66
94
|
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
95
|
+
response.to_hash[:multi_ref].each do |version|
|
96
|
+
all_versions << version[:name]
|
97
|
+
@next_version = version[:name] if next_version_id.to_i == version[:sequence].to_i
|
98
|
+
@actual_version = version[:name] if actual_version_id.to_i == version[:sequence].to_i
|
99
|
+
end
|
72
100
|
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
101
|
+
@all_versions = all_versions.sort_by { |x| x.split('.').map &:to_i }
|
102
|
+
raise Exceptions::CouldNotGetNextVersion, 'Problem getting Next Version number' if @next_version.nil?
|
103
|
+
raise Exceptions::CouldNotGetActualVersion, 'Problem getting Actual Version number' if @actual_version.nil?
|
104
|
+
return true
|
105
|
+
end
|
106
|
+
return false, error.to_s
|
78
107
|
rescue Savon::SOAPFault => e
|
79
108
|
tries = tries -= 1
|
80
|
-
|
109
|
+
if (tries).zero?
|
110
|
+
return false
|
111
|
+
else
|
81
112
|
sleep 5
|
82
113
|
self.token
|
83
114
|
puts "Jira connection failed. Trying to connect again. (Num tries: #{tries})"
|
84
115
|
retry
|
85
|
-
else
|
86
|
-
return false
|
87
116
|
end
|
88
117
|
end
|
89
118
|
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
119
|
+
#get all version id's of the project
|
120
|
+
#
|
121
|
+
# @param [Hash] response
|
122
|
+
# @return [Array] @version_id_array
|
94
123
|
def get_all_version_ids(response)
|
95
124
|
version_id_array = []
|
96
125
|
response.to_hash[:multi_ref].each do |version|
|
@@ -106,13 +135,14 @@ class JiraWsdl
|
|
106
135
|
# @param status - verify,in progress, open, reopened, closed
|
107
136
|
# @param project key or name
|
108
137
|
# @param version project version
|
109
|
-
# @param
|
138
|
+
# @param max_num_results max number of results
|
110
139
|
# @return nil, jira_tickets, (false, error_msg)
|
111
|
-
def get_jira_tickets(status, project, version,
|
140
|
+
def get_jira_tickets(status, project, version, max_num_results=300)
|
112
141
|
|
113
|
-
response = @client.call(:get_issues_from_jql_search,
|
114
|
-
|
115
|
-
|
142
|
+
response = @client.call(:get_issues_from_jql_search,
|
143
|
+
message: {:token => @token,
|
144
|
+
:jqlSearch => 'status in (' + status + ') and project=' + project + ' and fixVersion in (' + version + ')',
|
145
|
+
:maxNumResults => max_num_results})
|
116
146
|
#if response is empty
|
117
147
|
if response.to_hash[:multi_ref].nil?
|
118
148
|
nil
|
@@ -137,4 +167,6 @@ module Exceptions
|
|
137
167
|
end
|
138
168
|
class CouldNotGetActualVersion < StandardError;
|
139
169
|
end
|
170
|
+
class TokenNotCreated < StandardError;
|
171
|
+
end
|
140
172
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: jira-wsdl
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: savon
|
@@ -56,9 +56,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
56
56
|
version: '0'
|
57
57
|
requirements: []
|
58
58
|
rubyforge_project:
|
59
|
-
rubygems_version: 1.8.
|
59
|
+
rubygems_version: 1.8.23
|
60
60
|
signing_key:
|
61
61
|
specification_version: 3
|
62
62
|
summary: jira-wsdl
|
63
63
|
test_files: []
|
64
|
-
has_rdoc: false
|