BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
eff5746b
Commit
eff5746b
authored
Feb 19, 2018
by
Dmitriy Zaporozhets
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Redesign plugins system
Signed-off-by:
Dmitriy Zaporozhets
<
dmitriy.zaporozhets@gmail.com
>
parent
5bb435d0
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
30 deletions
+30
-30
system_hooks_service.rb
app/services/system_hooks_service.rb
+1
-8
plugin_worker.rb
app/workers/plugin_worker.rb
+9
-0
plugin.rb
lib/gitlab/plugin.rb
+14
-16
plugins.rake
lib/tasks/plugins.rake
+6
-6
No files found.
app/services/system_hooks_service.rb
View file @
eff5746b
...
...
@@ -12,14 +12,7 @@ class SystemHooksService
hook
.
async_execute
(
data
,
'system_hooks'
)
end
# Execute external plugins
Gitlab
::
Plugin
.
all
.
each
do
|
plugin
|
begin
plugin
.
new
.
execute
(
data
)
rescue
=>
e
Rails
.
logger
.
warn
(
"GitLab -> Plugins ->
#{
plugin
.
class
.
name
}
raised an axception during execution.
#{
e
}
"
)
end
end
Gitlab
::
Plugin
.
execute_all_async
(
data
)
end
private
...
...
app/workers/plugin_worker.rb
0 → 100644
View file @
eff5746b
class
PluginWorker
include
ApplicationWorker
sidekiq_options
retry:
false
def
perform
(
file_name
,
data
)
Gitlab
::
Plugin
.
execute
(
file_name
,
data
)
end
end
lib/gitlab/plugin.rb
View file @
eff5746b
module
Gitlab
module
Plugin
def
self
.
all
files
.
map
do
|
file
|
file_name
=
File
.
basename
(
file
,
'.rb'
)
def
self
.
files
Dir
.
glob
(
Rails
.
root
.
join
(
'plugins'
,
'*_plugin.rb'
))
end
# Just give sample data to method and expect it to not crash.
begin
klass
=
Object
.
const_get
(
file_name
.
classify
)
klass
.
new
.
execute
(
Gitlab
::
DataBuilder
::
Push
::
SAMPLE_DATA
)
rescue
=>
e
Rails
.
logger
.
warn
(
"GitLab -> Plugins ->
#{
file_name
}
raised an exception during boot check.
#{
e
}
"
)
next
else
Rails
.
logger
.
info
"GitLab -> Plugins ->
#{
file_name
}
passed validation check"
klass
end
def
self
.
execute_all_async
(
data
)
files
.
each
do
|
file
|
PluginWorker
.
perform_async
(
file
,
data
)
end
end
def
self
.
files
Dir
.
glob
(
Rails
.
root
.
join
(
'plugins'
,
'*_plugin.rb'
))
def
self
.
execute
(
file
,
data
)
# TODO: Implement
#
# Reuse some code from gitlab-shell https://gitlab.com/gitlab-org/gitlab-shell/blob/master/lib/gitlab_custom_hook.rb#L40
# Pass data as STDIN (or JSON encode?)
#
# 1. Return true if 0 exit code
# 2. Return false if non-zero exit code
end
end
end
lib/tasks/plugins.rake
View file @
eff5746b
...
...
@@ -27,13 +27,13 @@ namespace :plugins do
task
validate: :environment
do
puts
'Validating plugins from /plugins directory'
Gitlab
::
Plugin
.
all
.
each
do
|
plugin
|
begin
plugin
.
new
.
execute
(
Gitlab
::
DataBuilder
::
Push
::
SAMPLE_DATA
)
rescue
=>
e
puts
"
-
#{
plugin
}
raised an exception during boot check.
#{
e
}
"
Gitlab
::
Plugin
.
files
.
each
do
|
file
|
result
=
Gitlab
::
Plugin
.
execute
(
file
,
Gitlab
::
DataBuilder
::
Push
::
SAMPLE_DATA
)
if
result
puts
"
*
#{
file
}
succeed (zero exit code)
"
else
puts
"
-
#{
plugin
}
passed validation check
"
puts
"
*
#{
file
}
failure (non-zero exit code)
"
end
end
end
...
...
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