Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
e3f736d2
Commit
e3f736d2
authored
May 13, 2014
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Jira service.
parent
fcc32002
Changes
10
Show whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
129 additions
and
9 deletions
+129
-9
app/models/project.rb
app/models/project.rb
+6
-1
app/models/project_services/jira_service.rb
app/models/project_services/jira_service.rb
+95
-0
app/services/git_push_service.rb
app/services/git_push_service.rb
+5
-1
app/views/projects/services/_form.html.haml
app/views/projects/services/_form.html.haml
+2
-0
config/gitlab.yml.example
config/gitlab.yml.example
+1
-1
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-1
db/migrate/20140513095908_add_username_password_api_version_to_services.rb
...13095908_add_username_password_api_version_to_services.rb
+7
-0
db/schema.rb
db/schema.rb
+4
-1
lib/gitlab/markdown.rb
lib/gitlab/markdown.rb
+1
-1
lib/gitlab/reference_extractor.rb
lib/gitlab/reference_extractor.rb
+7
-3
No files found.
app/models/project.rb
View file @
e3f736d2
...
...
@@ -64,6 +64,7 @@ class Project < ActiveRecord::Base
has_one
:assembla_service
,
dependent: :destroy
has_one
:gemnasium_service
,
dependent: :destroy
has_one
:slack_service
,
dependent: :destroy
has_one
:jira_service
,
dependent: :destroy
has_one
:forked_project_link
,
dependent: :destroy
,
foreign_key:
"forked_to_project_id"
has_one
:forked_from_project
,
through: :forked_project_link
# Merge Requests for target project should be removed with it
...
...
@@ -316,13 +317,17 @@ class Project < ActiveRecord::Base
end
def
available_services_names
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack)
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla emails_on_push gemnasium slack
jira
)
end
def
gitlab_ci?
gitlab_ci_service
&&
gitlab_ci_service
.
active
end
def
jira_tracker?
self
.
issues_tracker
==
"jira"
end
# For compatibility with old code
def
code
path
...
...
app/models/project_services/jira_service.rb
0 → 100644
View file @
e3f736d2
# == Schema Information
#
# Table name: services
#
# id :integer not null, primary key
# type :string(255)
# title :string(255)
# token :string(255)
# project_id :integer not null
# created_at :datetime
# updated_at :datetime
# active :boolean default(FALSE), not null
# project_url :string(255)
# subdomain :string(255)
# room :string(255)
# recipients :text
# api_key :string(255)
# username :string(255)
# password :string(255)
class
JiraService
<
Service
include
HTTParty
attr_accessible
:project_url
,
:username
,
:password
,
:api_version
validates
:username
,
:password
,
presence:
true
,
if: :activated?
before_validation
:set_api_version
def
title
'JIRA'
end
def
description
'Bug, issue tracking, and project management system'
end
def
to_param
'jira'
end
def
fields
[
{
type:
'text'
,
name:
'project_url'
,
placeholder:
'Url to JIRA, http://jira.example'
},
{
type:
'text'
,
name:
'username'
,
placeholder:
''
},
{
type:
'password'
,
name:
'password'
,
placeholder:
''
},
{
type:
'text'
,
name:
'api_version'
,
placeholder:
'2'
}
]
end
def
set_api_version
self
.
api_version
=
"2"
end
def
execute
(
push
,
issue
=
nil
)
close_issue
(
push
,
issue
)
if
issue
end
private
def
close_issue
(
push_data
,
issue_name
)
url
=
close_issue_url
(
issue_name
)
commit_url
=
push_data
[
:commits
].
first
[
:url
]
message
=
{
'update'
=>
{
'comment'
=>
[{
'add'
=>
{
'body'
=>
"Issue solved with
#{
commit_url
}
"
}
}]
},
'transition'
=>
{
'id'
=>
'2'
}
}
JiraService
.
post
(
url
,
body:
message
.
to_json
,
headers:
{
'Content-Type'
=>
'application/json'
,
'Authorization'
=>
"Basic
#{
auth
}
"
}
)
end
def
close_issue_url
(
issue_name
)
"
#{
self
.
project_url
.
chomp
(
"/"
)
}
/rest/api/
#{
self
.
api_version
}
/issue/
#{
issue_name
}
/transitions"
end
def
auth
require
'base64'
Base64
.
urlsafe_encode64
(
"
#{
self
.
username
}
:
#{
self
.
password
}
"
)
end
end
app/services/git_push_service.rb
View file @
e3f736d2
...
...
@@ -88,9 +88,13 @@ class GitPushService
if
!
issues_to_close
.
empty?
&&
is_default_branch
issues_to_close
.
each
do
|
issue
|
if
project
.
jira_tracker?
&&
project
.
jira_service
.
active
project
.
jira_service
.
execute
(
push_data
,
issue
)
else
Issues
::
CloseService
.
new
(
project
,
author
,
{}).
execute
(
issue
,
commit
)
end
end
end
# Create cross-reference notes for any other references. Omit any issues that were referenced in an
# issue-closing phrase, or have already been mentioned from this commit (probably from this commit
...
...
app/views/projects/services/_form.html.haml
View file @
e3f736d2
...
...
@@ -37,6 +37,8 @@
=
f
.
text_area
name
,
rows:
5
,
class:
"form-control"
,
placeholder:
placeholder
-
elsif
type
==
'checkbox'
=
f
.
check_box
name
-
elsif
type
==
'password'
=
f
.
password_field
name
,
class:
"form-control"
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-save'
...
...
config/gitlab.yml.example
View file @
e3f736d2
...
...
@@ -74,7 +74,7 @@ production: &base
# If a commit message matches this regular expression, all issues referenced from the matched text will be closed.
# This happens when the commit is pushed or merged into the default branch of a project.
# When not specified the default issue_closing_pattern as specified below will be used.
# issue_closing_pattern: '([Cc]lose[sd]|[Ff]ixe[sd])
#(
\d+)'
# issue_closing_pattern: '([Cc]lose[sd]|[Ff]ixe[sd])
(#\d+|([A-Z\-]+-)
\d+)'
## Default project features settings
default_projects_features:
...
...
config/initializers/1_settings.rb
View file @
e3f736d2
...
...
@@ -91,7 +91,7 @@ Settings.gitlab['signup_enabled'] ||= false
Settings
.
gitlab
[
'signin_enabled'
]
||=
true
if
Settings
.
gitlab
[
'signin_enabled'
].
nil?
Settings
.
gitlab
[
'restricted_visibility_levels'
]
=
Settings
.
send
(
:verify_constant_array
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
[
'restricted_visibility_levels'
],
[])
Settings
.
gitlab
[
'username_changing_enabled'
]
=
true
if
Settings
.
gitlab
[
'username_changing_enabled'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'([Cc]lose[sd]|[Ff]ixe[sd])
#(
\d+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
Settings
.
gitlab
[
'issue_closing_pattern'
]
=
'([Cc]lose[sd]|[Ff]ixe[sd])
(#\d+|([A-Z\-]+-)
\d+)'
if
Settings
.
gitlab
[
'issue_closing_pattern'
].
nil?
Settings
.
gitlab
[
'default_projects_features'
]
||=
{}
Settings
.
gitlab
.
default_projects_features
[
'issues'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'issues'
].
nil?
Settings
.
gitlab
.
default_projects_features
[
'merge_requests'
]
=
true
if
Settings
.
gitlab
.
default_projects_features
[
'merge_requests'
].
nil?
...
...
db/migrate/20140513095908_add_username_password_api_version_to_services.rb
0 → 100644
View file @
e3f736d2
class
AddUsernamePasswordApiVersionToServices
<
ActiveRecord
::
Migration
def
change
add_column
:services
,
:username
,
:string
add_column
:services
,
:password
,
:string
add_column
:services
,
:api_version
,
:string
end
end
db/schema.rb
View file @
e3f736d2
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201405
02125220
)
do
ActiveRecord
::
Schema
.
define
(
version:
201405
13095908
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -280,6 +280,9 @@ ActiveRecord::Schema.define(version: 20140502125220) do
t
.
string
"room"
t
.
text
"recipients"
t
.
string
"api_key"
t
.
string
"username"
t
.
string
"password"
t
.
string
"api_version"
end
add_index
"services"
,
[
"project_id"
],
name:
"index_services_on_project_id"
,
using: :btree
...
...
lib/gitlab/markdown.rb
View file @
e3f736d2
...
...
@@ -181,7 +181,7 @@ module Gitlab
link_to
(
"#
#{
identifier
}
"
,
url
,
html_options
.
merge
(
title:
"Issue:
#{
title
}
"
,
class:
"gfm gfm-issue
#{
html_options
[
:class
]
}
"
))
end
else
reference_jira_issue
(
identifier
)
if
@project
.
issues_tracker
==
"jira"
reference_jira_issue
(
identifier
)
if
@project
.
jira_tracker?
end
end
...
...
lib/gitlab/reference_extractor.rb
View file @
e3f736d2
...
...
@@ -23,10 +23,14 @@ module Gitlab
end
def
issues_for
project
if
project
.
jira_tracker?
issues
.
uniq
else
issues
.
map
do
|
identifier
|
project
.
issues
.
where
(
iid:
identifier
).
first
end
.
reject
(
&
:nil?
)
end
end
def
merge_requests_for
project
merge_requests
.
map
do
|
identifier
|
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment