JOT 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile +14 -0
- data/LICENSE.txt +20 -0
- data/README.md +61 -0
- data/README.rdoc +19 -0
- data/Rakefile +62 -0
- data/VERSION +1 -0
- data/bin/JOT +158 -0
- data/example.erb +37 -0
- data/lib/JIRA-SOAP-STUBS/JiraSoapServiceServiceClient.rb +1921 -0
- data/lib/JIRA-SOAP-STUBS/default.rb +887 -0
- data/lib/JIRA-SOAP-STUBS/defaultDriver.rb +1141 -0
- data/lib/JIRA-SOAP-STUBS/defaultMappingRegistry.rb +1058 -0
- data/lib/extension_methods.rb +22 -0
- data/test/helper.rb +18 -0
- data/test/test_JOT.rb +7 -0
- metadata +156 -0
data/Gemfile
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
source "http://rubygems.org"
|
2
|
+
# Add dependencies required to use your gem here.
|
3
|
+
# Example:
|
4
|
+
# gem "activesupport", ">= 2.3.5"
|
5
|
+
gem "soap4r", ">= 1.5.8"
|
6
|
+
|
7
|
+
# Add dependencies to develop your gem here.
|
8
|
+
# Include everything needed to run rake, tests, features, etc.
|
9
|
+
group :development do
|
10
|
+
gem "shoulda", ">= 0"
|
11
|
+
gem "bundler", "~> 1.0.0"
|
12
|
+
gem "jeweler", "~> 1.6.4"
|
13
|
+
gem "rcov", ">= 0"
|
14
|
+
end
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Darrin Mison
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,61 @@
|
|
1
|
+
# ABOUT
|
2
|
+
This is a fairly simple Ruby script that uses SOAP to retrieve issues from a JIRA instance and pumps them into
|
3
|
+
a customizable ERB template.
|
4
|
+
|
5
|
+
# TESTED ON
|
6
|
+
|
7
|
+
* Ruby 1.8.7 on Mac OSX Snow Leopard.
|
8
|
+
* Ruby 1.8.6 on Fedora 13 64bit
|
9
|
+
|
10
|
+
# INSTALLING
|
11
|
+
1. Ensure Ruby is installed.
|
12
|
+
2. On Fedora 13, install the Ruby Gems package, `[localhost ]$ sudo yum install rubygems`
|
13
|
+
2. Install SOAP4R. `[localhost ]$ sudo gem install soap4r`
|
14
|
+
3. Download by clicking on the `Downloads` button above on the right and picking a archive format
|
15
|
+
4. Unzip it where you want it to go. Make sure you unzip into a directory so you don't end up with files everywhere.
|
16
|
+
4. Optionally add the new directory you created to your PATH, `PATH=$PATH:~/scripts/JOT/`
|
17
|
+
5. Make the `JOT.rb` file executable, `[localhost]$ chmod +x JOT.rb`
|
18
|
+
|
19
|
+
# RUNNING
|
20
|
+
Run `JOT.rb` and specify arguments as required. Not rocket science.
|
21
|
+
|
22
|
+
JOT.rb [options]
|
23
|
+
-s, --security Retrieve security levels. Slow, dont do it unless necessary
|
24
|
+
-t, --template FILE template to use
|
25
|
+
-u, --username USERNAME JIRA username
|
26
|
+
-p, --password PASSWORD JIRA password
|
27
|
+
-f, --filter FILTER JIRA filter
|
28
|
+
-h, --help Display this screen
|
29
|
+
|
30
|
+
E.g. : `[localhost]$ JOT.rb -u joe -p jf84hjf -f "Unresolved JIRAs for 4.8" -t overdue_issues_report.erb`
|
31
|
+
|
32
|
+
The error handling for the parameters is pretty terrible right now.
|
33
|
+
|
34
|
+
You need to supply:
|
35
|
+
|
36
|
+
1. `-u` and `-p` for your username and password to authenticate
|
37
|
+
2. `-f` to specify the filter that you are retrieving the list of issues from
|
38
|
+
3. `-t` to specify the template that is to be used to format the output
|
39
|
+
|
40
|
+
The only optional parameters right now are `-h` and `-s`.
|
41
|
+
|
42
|
+
* `-h` displays the help and exits.
|
43
|
+
* -s forces it to retrieve the security level information for each issue as well, this is much slower and
|
44
|
+
shouldn't be used unless you need that information.
|
45
|
+
|
46
|
+
Currently you can only retrieve data based on a filter that you have "favorited" in JIRA, so you must be
|
47
|
+
authenticated.
|
48
|
+
|
49
|
+
An example template, `example.erb`, is included. This template is an example of producing a Docbook XML
|
50
|
+
variablelist from some custom fields. Currently this template assumes that the security level information has
|
51
|
+
been requested and produces slightly weird output if you haven't specified `-s`.
|
52
|
+
|
53
|
+
# CREATING CUSTOM TEMPLATES
|
54
|
+
Different templates can be supplied using the `-t` parameter. These templates must be written in Embedded
|
55
|
+
Ruby, see <http://en.wikipedia.org/wiki/ERuby>. I hope to be adding more example files in the future.
|
56
|
+
|
57
|
+
Note that although the wikipedia page talks about Embedded Ruby in the specific context of generating HTML
|
58
|
+
output this is not a limitation. The template doesn't care about anything outside of the `<%` `%>` tags. It
|
59
|
+
could be used to produce HTML, XML, CSV or any other text based format you want.
|
60
|
+
|
61
|
+
|
data/README.rdoc
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
= JOT
|
2
|
+
|
3
|
+
Description goes here.
|
4
|
+
|
5
|
+
== Contributing to JOT
|
6
|
+
|
7
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
8
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
9
|
+
* Fork the project
|
10
|
+
* Start a feature/bugfix branch
|
11
|
+
* Commit and push until you are happy with your contribution
|
12
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
13
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
14
|
+
|
15
|
+
== Copyright
|
16
|
+
|
17
|
+
Copyright (c) 2011 Darrin Mison. See LICENSE.txt for
|
18
|
+
further details.
|
19
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'bundler'
|
5
|
+
begin
|
6
|
+
Bundler.setup(:default, :development)
|
7
|
+
rescue Bundler::BundlerError => e
|
8
|
+
$stderr.puts e.message
|
9
|
+
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
+
exit e.status_code
|
11
|
+
end
|
12
|
+
require 'rake'
|
13
|
+
|
14
|
+
require 'jeweler'
|
15
|
+
Jeweler::Tasks.new do |gem|
|
16
|
+
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
17
|
+
gem.name = "JOT"
|
18
|
+
gem.homepage = "http://github.com/dmison/JOT"
|
19
|
+
gem.license = "MIT"
|
20
|
+
gem.summary = "CLI for retreiving issues from a JIRA instance and formatting the data."
|
21
|
+
gem.description = "Uses the JIRA SOAP interface to retrieve issues from a JIRA instance for processing with a user specified ERB template."
|
22
|
+
gem.email = "dmison@me.com"
|
23
|
+
gem.authors = ["Darrin Mison"]
|
24
|
+
#files
|
25
|
+
#gem.files = FileList["{bin/*,lib/*,lib/**/*}"].to_a
|
26
|
+
gem.files.include 'bin/*'
|
27
|
+
gem.files.include 'lib/*.rb'
|
28
|
+
gem.files.include 'lib/**/*.rb'
|
29
|
+
gem.files.exclude 'test'
|
30
|
+
gem.require_path = "lib"
|
31
|
+
gem.executables = "JOT"
|
32
|
+
|
33
|
+
# dependencies defined in Gemfile
|
34
|
+
end
|
35
|
+
Jeweler::RubygemsDotOrgTasks.new
|
36
|
+
|
37
|
+
require 'rake/testtask'
|
38
|
+
Rake::TestTask.new(:test) do |test|
|
39
|
+
test.libs << 'lib' << 'test'
|
40
|
+
test.pattern = 'test/**/test_*.rb'
|
41
|
+
test.verbose = true
|
42
|
+
end
|
43
|
+
|
44
|
+
require 'rcov/rcovtask'
|
45
|
+
Rcov::RcovTask.new do |test|
|
46
|
+
test.libs << 'test'
|
47
|
+
test.pattern = 'test/**/test_*.rb'
|
48
|
+
test.verbose = true
|
49
|
+
test.rcov_opts << '--exclude "gems/*"'
|
50
|
+
end
|
51
|
+
|
52
|
+
task :default => :test
|
53
|
+
|
54
|
+
require 'rake/rdoctask'
|
55
|
+
Rake::RDocTask.new do |rdoc|
|
56
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
57
|
+
|
58
|
+
rdoc.rdoc_dir = 'rdoc'
|
59
|
+
rdoc.title = "JOT #{version}"
|
60
|
+
rdoc.rdoc_files.include('README*')
|
61
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.2
|
data/bin/JOT
ADDED
@@ -0,0 +1,158 @@
|
|
1
|
+
#!/usr/bin/env ruby -W0
|
2
|
+
$LOAD_PATH.unshift File.dirname(__FILE__)
|
3
|
+
|
4
|
+
require 'rubygems'
|
5
|
+
require 'erb'
|
6
|
+
require 'soap/driver'
|
7
|
+
require 'optparse'
|
8
|
+
|
9
|
+
require 'JIRA-SOAP-STUBS/defaultDriver.rb'
|
10
|
+
require 'extension_methods.rb'
|
11
|
+
|
12
|
+
#http://docs.atlassian.com/software/jira/docs/api/rpc-jira-plugin/latest/com/atlassian/jira/rpc/soap/JiraSoapService.html
|
13
|
+
#wsdl2ruby.rb --wsdl http://issues.jboss.org/rpc/soap/jirasoapservice-v2?wsdl --type=client --module JIRA
|
14
|
+
|
15
|
+
def fatalError(message)
|
16
|
+
puts "ERROR COMMUNICATING WITH JIRA:"
|
17
|
+
puts "\t #{message}"
|
18
|
+
exit
|
19
|
+
end
|
20
|
+
|
21
|
+
# ========================================
|
22
|
+
def getFilterID(name, token, driver)
|
23
|
+
favFilters = driver.getFavouriteFilters(token)
|
24
|
+
favFilters.each do |filter|
|
25
|
+
if filter.name == name then
|
26
|
+
return filter.id
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# ========================================
|
32
|
+
def populateSecurityLevels(issues, soapdriver,loginToken)
|
33
|
+
issues.each do | issue |
|
34
|
+
issue.security_level = soapdriver.getSecurityLevel(loginToken, issue.key).name
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
# ========================================
|
39
|
+
def getIssuesFromFilter( username, password, filter, getSecurityLevels)
|
40
|
+
soapdriver = JIRA::JiraSoapService.new
|
41
|
+
|
42
|
+
begin
|
43
|
+
loginToken = soapdriver.login(username, password)
|
44
|
+
rescue SocketError
|
45
|
+
fatalError("Couldn't open connection. Check your network.")
|
46
|
+
rescue StandardError
|
47
|
+
fatalError("Login failed.")
|
48
|
+
end
|
49
|
+
|
50
|
+
filterID = getFilterID(filter, loginToken, soapdriver)
|
51
|
+
issues = soapdriver.getIssuesFromFilter(loginToken, filterID)
|
52
|
+
if (getSecurityLevels) then
|
53
|
+
populateSecurityLevels(issues, soapdriver, loginToken)
|
54
|
+
end
|
55
|
+
return issues
|
56
|
+
end
|
57
|
+
|
58
|
+
# ========================================
|
59
|
+
def getTemplateOutputForIssues(template_file, issues)
|
60
|
+
begin
|
61
|
+
template = ERB.new File.new(template_file).read, nil, "%"
|
62
|
+
template.result(binding)
|
63
|
+
return template.result(binding)
|
64
|
+
rescue => error
|
65
|
+
fatalError("\t#{error.to_s}")
|
66
|
+
exit
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
# ======================================== read commandline parameters
|
71
|
+
def processCommandLine
|
72
|
+
options = {}
|
73
|
+
|
74
|
+
optparse = OptionParser.new do |opts|
|
75
|
+
opts.banner = "JOT.rb [options]"
|
76
|
+
|
77
|
+
options[:getSecurityLevels] = false
|
78
|
+
opts.on( '-s', '--security', 'Retrieve security levels. Slow, don''t do it unless necessary' ) do
|
79
|
+
options[:getSecurityLevels] = true
|
80
|
+
end
|
81
|
+
|
82
|
+
options[:template_file] = ""
|
83
|
+
opts.on( '-t FILE', '--template FILE', 'template to use' ) do | file |
|
84
|
+
options[:template_file] = file
|
85
|
+
end
|
86
|
+
|
87
|
+
options[:username] = ""
|
88
|
+
opts.on( '-u USERNAME', '--username USERNAME', 'JIRA username' ) do | username |
|
89
|
+
options[:username] = username
|
90
|
+
end
|
91
|
+
|
92
|
+
options[:password] = ""
|
93
|
+
opts.on( '-p PASSWORD', '--password PASSWORD', 'JIRA password' ) do | password |
|
94
|
+
options[:password] = password
|
95
|
+
end
|
96
|
+
|
97
|
+
options[:filter] = ""
|
98
|
+
opts.on( '-f FILTER', '--filter FILTER', 'JIRA filter' ) do | filter |
|
99
|
+
options[:filter] = filter
|
100
|
+
end
|
101
|
+
|
102
|
+
options[:query] = ""
|
103
|
+
opts.on( '-q QUERY', '--query QUERY', 'JQL Query [NOT IMPLEMENTED YET]' ) do | query |
|
104
|
+
options[:query] = query
|
105
|
+
end
|
106
|
+
|
107
|
+
opts.on( '-h', '--help', 'Display this screen' ) do
|
108
|
+
puts opts
|
109
|
+
exit
|
110
|
+
end
|
111
|
+
|
112
|
+
if (ARGV.size == 0) then
|
113
|
+
puts opts
|
114
|
+
exit
|
115
|
+
end
|
116
|
+
|
117
|
+
|
118
|
+
end
|
119
|
+
|
120
|
+
|
121
|
+
begin
|
122
|
+
optparse.parse!
|
123
|
+
rescue => error
|
124
|
+
puts "ERROR PARSING COMMANDLINE:"
|
125
|
+
puts "\t"+error.to_s
|
126
|
+
puts
|
127
|
+
puts optparse
|
128
|
+
exit
|
129
|
+
end
|
130
|
+
if (options[:query] != "" and options[:filter] != "") then
|
131
|
+
puts "ERROR PARSING COMMANDLINE:"
|
132
|
+
puts "\tOnly specify a JQL query with -q or a filter with -f, not both."
|
133
|
+
puts
|
134
|
+
puts optparse
|
135
|
+
exit
|
136
|
+
end
|
137
|
+
|
138
|
+
|
139
|
+
return options
|
140
|
+
end
|
141
|
+
|
142
|
+
# ========================================
|
143
|
+
options = processCommandLine
|
144
|
+
|
145
|
+
if (options[:template_file] == "") then
|
146
|
+
issues = getIssuesFromFilter(options[:username], options[:password], options[:filter], options[:getSecurityLevels])
|
147
|
+
|
148
|
+
issues.each do |issue|
|
149
|
+
puts issue.inspect
|
150
|
+
end
|
151
|
+
|
152
|
+
else
|
153
|
+
|
154
|
+
puts getTemplateOutputForIssues(
|
155
|
+
options[:template_file],
|
156
|
+
getIssuesFromFilter(options[:username], options[:password], options[:filter], options[:getSecurityLevels])
|
157
|
+
)
|
158
|
+
end
|
data/example.erb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
<?xml version='1.0'?>
|
2
|
+
<!DOCTYPE variablelist PUBLIC "-//OASIS//DTD DocBook XML V4.5//EN" "http://www.oasis-open.org/docbook/xml/4.5/docbookx.dtd" [
|
3
|
+
]>
|
4
|
+
|
5
|
+
<% siteURL="https://issues.jboss.org/browse" %>
|
6
|
+
<variablelist>
|
7
|
+
<% issues.each do |issue|
|
8
|
+
release_note_text = issue.getCustomFieldValueForID("customfield_12310211").to_s
|
9
|
+
|
10
|
+
#if the first line of RNText starts with siteURL
|
11
|
+
finalURL = release_note_text.split("\n")[0].to_s
|
12
|
+
if finalURL.start_with?(siteURL) then
|
13
|
+
release_note_text = release_note_text.gsub(finalURL+"\n","")
|
14
|
+
else
|
15
|
+
finalURL = siteURL+"/"+issue.key
|
16
|
+
end
|
17
|
+
%>
|
18
|
+
<!-- <%= siteURL %>/<%= issue.key %> -->
|
19
|
+
<varlistentry>
|
20
|
+
<term><ulink url="<%= finalURL %>" /></term>
|
21
|
+
<listitem>
|
22
|
+
<% if (issue.security_level == "Public") then %>
|
23
|
+
<para>
|
24
|
+
<%= release_note_text.to_x %>
|
25
|
+
</para>
|
26
|
+
<% else %>
|
27
|
+
<warning>
|
28
|
+
<title>Not Public Yet - <%= issue.security_level %></title>
|
29
|
+
<para>
|
30
|
+
<%= release_note_text.to_x %>
|
31
|
+
</para>
|
32
|
+
</warning>
|
33
|
+
<% end %>
|
34
|
+
</listitem>
|
35
|
+
</varlistentry>
|
36
|
+
<% end %>
|
37
|
+
</variablelist>
|