jiraSOAP 0.8.1 → 0.8.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/.yardopts +1 -0
- data/ChangeLog +17 -2
- data/docs/Examples.markdown +119 -0
- data/docs/GettingStarted.markdown +2 -0
- data/lib/jiraSOAP/api/additions.rb +2 -1
- data/lib/jiraSOAP/api/issue_data_types.rb +7 -0
- data/lib/jiraSOAP/api/issues.rb +2 -2
- data/lib/jiraSOAP/api/projects.rb +24 -31
- data/lib/jiraSOAP/entities/attachment_metadata.rb +2 -0
- data/lib/jiraSOAP/entities/avatar.rb +2 -0
- data/lib/jiraSOAP/entities/field_value.rb +2 -0
- data/lib/jiraSOAP/entities/issue.rb +10 -0
- data/lib/jiraSOAP/entities/issue_type.rb +1 -0
- data/lib/jiraSOAP/entities/username.rb +2 -0
- data/lib/jiraSOAP/version.rb +1 -1
- metadata +3 -1
data/.yardopts
CHANGED
data/ChangeLog
CHANGED
@@ -1,16 +1,31 @@
|
|
1
|
+
Version 0.8.2
|
2
|
+
|
3
|
+
* Added Issue#custom_field for getting custom field values
|
4
|
+
* Added a file of examples, ported from jira4r
|
5
|
+
* Add setters to attribute aliases
|
6
|
+
* Added a forgotten deprecation
|
7
|
+
* Updated ChangeLog with changes from 0.8.1
|
8
|
+
* Updated ChangeLog with changes from 0.8.0 (sorry!)
|
9
|
+
|
10
|
+
Version 0.8.1
|
11
|
+
|
12
|
+
* Updated README and GettingStarted guide
|
13
|
+
|
1
14
|
Version 0.8.0
|
2
15
|
|
3
16
|
* Deprecated the #get_ from methods that start with #get_
|
4
17
|
* Alias #login to #log_in and #logout to #log_out
|
5
18
|
* Added RemoteAPI#permission_to_edit_comment?
|
6
19
|
* Added UserGroup and related RemoteAPI methods
|
7
|
-
* Added RemoteAPI#add_worklog
|
20
|
+
* Added RemoteAPI#add_worklog (thanks @FDj)
|
21
|
+
* Added ability to initialize JIRA::FieldValue without an array (thanks @knut)
|
22
|
+
|
8
23
|
* Various documentation updates and tweaks
|
9
24
|
|
10
25
|
* Removed handsoap parsing abstraction (roflscale for parsing)
|
11
26
|
* Removed the YARD plugin in favour of YARD 0.7 DSL documenting stuff
|
12
27
|
|
13
|
-
*
|
28
|
+
* Fix setting the assignee during Issue creation (thanks @ssmiech)
|
14
29
|
|
15
30
|
Version 0.7.1
|
16
31
|
|
@@ -0,0 +1,119 @@
|
|
1
|
+
# Examples
|
2
|
+
|
3
|
+
These snippets showcase ways to interact with a JIRA server via JIRA's
|
4
|
+
SOAP interface. The script was originally adapted from an example
|
5
|
+
script for jira4r.
|
6
|
+
|
7
|
+
## The first thing you need to do
|
8
|
+
|
9
|
+
Always start by creating a new {JIRA::JIRAService}, with the argument
|
10
|
+
being the base URL to your JIRA server
|
11
|
+
(e.g. http://confluence.atlassian.com):
|
12
|
+
|
13
|
+
jira = JIRA::JIRAService.new 'http://jira.atlassian.com:8080'
|
14
|
+
|
15
|
+
Then you need to log in:
|
16
|
+
|
17
|
+
jira.login 'soaptester', 'password'
|
18
|
+
|
19
|
+
Now the rest of the API is available to you.
|
20
|
+
|
21
|
+
## Server Information
|
22
|
+
|
23
|
+
You can get information about the server, such as its version, and
|
24
|
+
also information about its configuration, such as whether or not
|
25
|
+
voting on issues is allowed:
|
26
|
+
|
27
|
+
baseurl = jira.server_info.base_url
|
28
|
+
puts "Base URL: #{baseurl} \n"
|
29
|
+
|
30
|
+
if jira.server_configuration.voting_allowed?
|
31
|
+
puts 'Voting is allowed on this server'
|
32
|
+
else
|
33
|
+
puts 'Voting is not allowed on this server'
|
34
|
+
end
|
35
|
+
|
36
|
+
## Project Information
|
37
|
+
|
38
|
+
Getting information about projects is also very easy, except for
|
39
|
+
information about schemes (i.e. permissions, etc.).
|
40
|
+
|
41
|
+
# get every project
|
42
|
+
projects = jira.projects.each { |project| puts project.inspect }
|
43
|
+
|
44
|
+
# get a specific project
|
45
|
+
project_key = 'DEMO'
|
46
|
+
project = jira.project_with_key project_key
|
47
|
+
puts "Details for project #{project_key}: #{project.inspect}"
|
48
|
+
|
49
|
+
### Project Versions
|
50
|
+
|
51
|
+
version = JIRA::Version.new
|
52
|
+
version.name = 'version 99'
|
53
|
+
new_version = jira.add_version_to_project_with_key project.key, version
|
54
|
+
puts "Added version #{new_version.name} to #{project.name}\n"
|
55
|
+
|
56
|
+
## Issues
|
57
|
+
|
58
|
+
There are many ways to get and issue from the server, I think the
|
59
|
+
easiest is to use the issue key.
|
60
|
+
|
61
|
+
issue_key = 'TST-10392'
|
62
|
+
issue = jira.issue_with_key issue_key
|
63
|
+
puts "Retrieved issue: #{issue.key}: #{issue.summary}\n"
|
64
|
+
|
65
|
+
### Get the value of a custom field
|
66
|
+
|
67
|
+
I find that I often need to get information from an issue's custom fields.
|
68
|
+
|
69
|
+
custom_field_id = jira.custom_field_with_name('Reported on behalf of').id
|
70
|
+
custom_field_value = issue.custom_field(custom_field_id)
|
71
|
+
puts "Value of issue #{issue.key}'s custom field with ID #{custom_field_id}: " +
|
72
|
+
"#{custom_field_value}\n"
|
73
|
+
|
74
|
+
### Comment on an issue
|
75
|
+
|
76
|
+
It is also pretty easy to add a comment to an issue.
|
77
|
+
|
78
|
+
comment = JIRA::Comment.new
|
79
|
+
comment.body = 'commented from jiraSOAP'
|
80
|
+
jira.add_comment_to_issue_with_key issue.key, comment
|
81
|
+
|
82
|
+
### Update a field for an issue
|
83
|
+
|
84
|
+
Updating an issue is easy, but has some caveats, so you should see the
|
85
|
+
documentation as well ({JIRA::RemoteAPI#update_issue}).
|
86
|
+
|
87
|
+
summary = JIRA::FieldValue.new('summary', 'new summary info from jiraSOAP')
|
88
|
+
jira.update_issue issue.key, summary
|
89
|
+
puts "Updated issue #{issue.key}'s field #{summary.name}\n"
|
90
|
+
|
91
|
+
## User Information
|
92
|
+
|
93
|
+
CRUD operations for user information are also available.
|
94
|
+
|
95
|
+
begin
|
96
|
+
password = rand(1000000000000).to_s(16)
|
97
|
+
user = jira.create_user('jon', password, 'Jon Happy', 'jon@usa.com')
|
98
|
+
puts "Created user #{user.username} with password: #{password}\n"
|
99
|
+
rescue
|
100
|
+
end
|
101
|
+
|
102
|
+
### User groups
|
103
|
+
|
104
|
+
# get details about a user group
|
105
|
+
group = jira.group_with_name 'jira-users'
|
106
|
+
puts "Retrieved details for group jira-users: #{group.inspect}\n"
|
107
|
+
|
108
|
+
# add a user to a group
|
109
|
+
newuser = JIRA::User.new
|
110
|
+
newuser.name = user.name
|
111
|
+
jira.add_user_to_group group, user
|
112
|
+
puts "Added user #{user.name} in group #{group.name}\n"
|
113
|
+
|
114
|
+
## Don't forget to log out
|
115
|
+
|
116
|
+
Your session will timeout, but for security purposes it is always a
|
117
|
+
good idea to log out when you are done.
|
118
|
+
|
119
|
+
jira.logout
|
@@ -33,6 +33,8 @@ Don't forget to log out when you are done:
|
|
33
33
|
|
34
34
|
db.logout
|
35
35
|
|
36
|
+
See {file:docs/Examples.rb} for more examples.
|
37
|
+
|
36
38
|
To find out what APIs are available, check out the {JIRA::RemoteAPI}
|
37
39
|
module, as well as the {JIRA::RemoteAPIAdditions} module for
|
38
40
|
conveniences that `jiraSOAP` has added.
|
@@ -10,11 +10,12 @@ module JIRA::RemoteAPIAdditions
|
|
10
10
|
#
|
11
11
|
# @param [String] name
|
12
12
|
# @return [JIRA::Field,nil]
|
13
|
-
def
|
13
|
+
def custom_field_with_name name
|
14
14
|
get_custom_fields.each { |cf|
|
15
15
|
return cf if cf.name == name
|
16
16
|
}
|
17
17
|
nil
|
18
18
|
end
|
19
|
+
alias_method :get_custom_field_with_name, :custom_field_with_name
|
19
20
|
|
20
21
|
end
|
@@ -26,6 +26,13 @@ module JIRA::RemoteAPI
|
|
26
26
|
end
|
27
27
|
alias_method :get_issue_types, :issue_types
|
28
28
|
|
29
|
+
# @param [String] project_name
|
30
|
+
# @return [Array<JIRA::IssueType>]
|
31
|
+
def issue_types_for_project_with_id project_id
|
32
|
+
array_jira_call JIRA::IssueType, 'getIssueTypesForProject', project_id
|
33
|
+
end
|
34
|
+
alias_method :get_issue_types_for_project_with_id, :issue_types_for_project_with_id
|
35
|
+
|
29
36
|
# @return [Array<JIRA::Status>]
|
30
37
|
def statuses
|
31
38
|
array_jira_call JIRA::Status, 'getStatuses'
|
data/lib/jiraSOAP/api/issues.rb
CHANGED
@@ -38,9 +38,9 @@ module JIRA::RemoteAPI
|
|
38
38
|
# update.
|
39
39
|
#
|
40
40
|
# @example Usage With A Normal Field
|
41
|
-
# summary = JIRA::FieldValue.new 'summary',
|
41
|
+
# summary = JIRA::FieldValue.new 'summary', 'My new summary'
|
42
42
|
# @example Usage With A Custom Field
|
43
|
-
# custom_field = JIRA::FieldValue.new 'customfield_10060',
|
43
|
+
# custom_field = JIRA::FieldValue.new 'customfield_10060', '123456'
|
44
44
|
# @example Setting a field to be blank/nil
|
45
45
|
# description = JIRA::FieldValue.new 'description'
|
46
46
|
# @example Calling the method to update an issue
|
@@ -14,28 +14,6 @@ module JIRA::RemoteAPI
|
|
14
14
|
end
|
15
15
|
alias_method :get_project_with_key, :project_with_key
|
16
16
|
|
17
|
-
##
|
18
|
-
# Requires you to set at least a project name, key, and lead.
|
19
|
-
# However, it is also a good idea to set other project properties, such as
|
20
|
-
# the permission scheme as the default permission scheme can be too
|
21
|
-
# restrictive in most cases.
|
22
|
-
#
|
23
|
-
# @param [JIRA::Project] project
|
24
|
-
# @return [JIRA::Project]
|
25
|
-
def create_project_with_project project
|
26
|
-
JIRA::Project.new_with_xml jira_call( 'createProjectFromObject', project )
|
27
|
-
end
|
28
|
-
|
29
|
-
##
|
30
|
-
# The id of the project is the only field that you cannot update. Or, at
|
31
|
-
# least the only field I know that you cannot update.
|
32
|
-
#
|
33
|
-
# @param [JIRA::Project] project
|
34
|
-
# @return [JIRA::Project]
|
35
|
-
def update_project_with_project project
|
36
|
-
JIRA::Project.new_with_xml jira_call( 'updateProject', project )
|
37
|
-
end
|
38
|
-
|
39
17
|
# @param [String] project_id
|
40
18
|
# @return [JIRA::Project]
|
41
19
|
def project_with_id project_id
|
@@ -54,21 +32,36 @@ module JIRA::RemoteAPI
|
|
54
32
|
end
|
55
33
|
alias_method :get_project_including_schemes_with_id, :project_including_schemes_with_id
|
56
34
|
|
57
|
-
# @param [String] project_name
|
58
|
-
# @return [Array<JIRA::IssueType>]
|
59
|
-
def issue_types_for_project_with_id project_id
|
60
|
-
array_jira_call JIRA::IssueType, 'getIssueTypesForProject', project_id
|
61
|
-
end
|
62
|
-
alias_method :get_issue_types_for_project_with_id, :issue_types_for_project_with_id
|
63
|
-
|
64
35
|
##
|
65
36
|
# @note This will not fill in {JIRA::Scheme} data for the projects.
|
66
37
|
#
|
67
38
|
# @return [Array<JIRA::Project>]
|
68
|
-
def
|
39
|
+
def projects
|
69
40
|
array_jira_call JIRA::Project, 'getProjectsNoSchemes'
|
70
41
|
end
|
71
|
-
alias_method :
|
42
|
+
alias_method :get_projects, :projects
|
43
|
+
|
44
|
+
##
|
45
|
+
# Requires you to set at least a project name, key, and lead.
|
46
|
+
# However, it is also a good idea to set other project properties, such as
|
47
|
+
# the permission scheme as the default permission scheme can be too
|
48
|
+
# restrictive in most cases.
|
49
|
+
#
|
50
|
+
# @param [JIRA::Project] project
|
51
|
+
# @return [JIRA::Project]
|
52
|
+
def create_project_with_project project
|
53
|
+
JIRA::Project.new_with_xml jira_call( 'createProjectFromObject', project )
|
54
|
+
end
|
55
|
+
|
56
|
+
##
|
57
|
+
# The id of the project is the only field that you cannot update. Or, at
|
58
|
+
# least the only field I know that you cannot update.
|
59
|
+
#
|
60
|
+
# @param [JIRA::Project] project
|
61
|
+
# @return [JIRA::Project]
|
62
|
+
def update_project_with_project project
|
63
|
+
JIRA::Project.new_with_xml jira_call( 'updateProject', project )
|
64
|
+
end
|
72
65
|
|
73
66
|
# @param [String] project_key
|
74
67
|
# @return [Boolean] true if successful
|
@@ -10,10 +10,12 @@ class JIRA::AttachmentMetadata < JIRA::NamedEntity
|
|
10
10
|
# @return [String]
|
11
11
|
add_attribute :file_name, 'filename', :content
|
12
12
|
alias_method :filename, :file_name
|
13
|
+
alias_method :filename=, :file_name=
|
13
14
|
|
14
15
|
# @return [String]
|
15
16
|
add_attribute :mime_type, 'mimetype', :content
|
16
17
|
alias_method :content_type, :mime_type
|
18
|
+
alias_method :content_type=, :mime_type=
|
17
19
|
|
18
20
|
##
|
19
21
|
# Measured in bytes
|
@@ -19,10 +19,12 @@ class JIRA::Avatar < JIRA::DynamicEntity
|
|
19
19
|
# @return [String]
|
20
20
|
add_attribute :mime_type, 'contentType', :content
|
21
21
|
alias_method :content_type, :mime_type
|
22
|
+
alias_method :content_type=, :mime_type=
|
22
23
|
|
23
24
|
# @return [String]
|
24
25
|
add_attribute :base64_data, 'base64Data', :content
|
25
26
|
alias_method :data, :base64_data
|
27
|
+
alias_method :data=, :base64_data=
|
26
28
|
|
27
29
|
##
|
28
30
|
# Indicates if the image is the system default
|
@@ -24,7 +24,9 @@ class JIRA::FieldValue
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
##
|
27
28
|
# @todo soapify properly for custom objects (JIRA module).
|
29
|
+
#
|
28
30
|
# @param [Handsoap::XmlMason::Node] message the node to add the object to
|
29
31
|
# @param [String] label name for the tags that wrap the message
|
30
32
|
# @return [Handsoap::XmlMason::Element]
|
@@ -74,6 +74,16 @@ class JIRA::Issue < JIRA::DynamicEntity
|
|
74
74
|
# @return [Array<String>]
|
75
75
|
add_attribute :attachment_names, 'attachmentNames', :contents_of_children
|
76
76
|
|
77
|
+
##
|
78
|
+
# Get the value of a custom field given the custom field id, returns
|
79
|
+
# nil if the issue does not have a value for that field.
|
80
|
+
#
|
81
|
+
# @param [String] id the custom field id (e.g. 'customfield_10150')
|
82
|
+
# @return [JIRA::CustomFieldValue,nil]
|
83
|
+
def custom_field id
|
84
|
+
custom_field_values.find { |field_value| field_value.id == id }
|
85
|
+
end
|
86
|
+
|
77
87
|
##
|
78
88
|
# @todo see if we can use the simple and complex array builders
|
79
89
|
#
|
data/lib/jiraSOAP/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: jiraSOAP
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.8.
|
5
|
+
version: 0.8.2
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Mark Rada
|
@@ -80,6 +80,7 @@ extra_rdoc_files:
|
|
80
80
|
- LICENSE.txt
|
81
81
|
- .yardopts
|
82
82
|
- docs/GettingStarted.markdown
|
83
|
+
- docs/Examples.markdown
|
83
84
|
files:
|
84
85
|
- lib/jiraSOAP/api/additions.rb
|
85
86
|
- lib/jiraSOAP/api/attachments.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- LICENSE.txt
|
148
149
|
- .yardopts
|
149
150
|
- docs/GettingStarted.markdown
|
151
|
+
- docs/Examples.markdown
|
150
152
|
homepage: http://github.com/Marketcircle/jiraSOAP
|
151
153
|
licenses:
|
152
154
|
- MIT
|