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
ae5f124e
Commit
ae5f124e
authored
Jul 28, 2016
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP, initial work to implement pipeline hooks:
I might be squashing this commit in the future.
parent
9b0e131b
Changes
8
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
107 additions
and
0 deletions
+107
-0
app/controllers/projects/hooks_controller.rb
app/controllers/projects/hooks_controller.rb
+1
-0
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+6
-0
app/models/hooks/project_hook.rb
app/models/hooks/project_hook.rb
+1
-0
app/models/hooks/web_hook.rb
app/models/hooks/web_hook.rb
+1
-0
app/models/service.rb
app/models/service.rb
+1
-0
db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb
...igrate/20160728081025_add_pipeline_events_to_web_hooks.rb
+16
-0
db/migrate/20160728103734_add_pipeline_events_to_services.rb
db/migrate/20160728103734_add_pipeline_events_to_services.rb
+16
-0
lib/gitlab/data_builder/pipeline_data_builder.rb
lib/gitlab/data_builder/pipeline_data_builder.rb
+65
-0
No files found.
app/controllers/projects/hooks_controller.rb
View file @
ae5f124e
...
...
@@ -56,6 +56,7 @@ class Projects::HooksController < Projects::ApplicationController
def
hook_params
params
.
require
(
:hook
).
permit
(
:build_events
,
:pipeline_events
,
:enable_ssl_verification
,
:issues_events
,
:merge_requests_events
,
...
...
app/models/ci/pipeline.rb
View file @
ae5f124e
...
...
@@ -213,6 +213,12 @@ module Ci
]
end
def
execute_hooks
pipeline_data
=
Gitlab
::
DataBuilder
::
PipelineDataBuilder
.
build
(
self
)
project
.
execute_hooks
(
pipeline_data
.
dup
,
:pipeline_hooks
)
project
.
execute_services
(
pipeline_data
.
dup
,
:pipeline_hooks
)
end
private
def
build_builds_for_stages
(
stages
,
user
,
status
,
trigger_request
)
...
...
app/models/hooks/project_hook.rb
View file @
ae5f124e
...
...
@@ -5,5 +5,6 @@ class ProjectHook < WebHook
scope
:note_hooks
,
->
{
where
(
note_events:
true
)
}
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
)
}
scope
:pipeline_hooks
,
->
{
where
(
pipeline_events:
true
)
}
scope
:wiki_page_hooks
,
->
{
where
(
wiki_page_events:
true
)
}
end
app/models/hooks/web_hook.rb
View file @
ae5f124e
...
...
@@ -8,6 +8,7 @@ class WebHook < ActiveRecord::Base
default_value_for
:merge_requests_events
,
false
default_value_for
:tag_push_events
,
false
default_value_for
:build_events
,
false
default_value_for
:pipeline_events
,
false
default_value_for
:enable_ssl_verification
,
true
scope
:push_hooks
,
->
{
where
(
push_events:
true
)
}
...
...
app/models/service.rb
View file @
ae5f124e
...
...
@@ -36,6 +36,7 @@ class Service < ActiveRecord::Base
scope
:merge_request_hooks
,
->
{
where
(
merge_requests_events:
true
,
active:
true
)
}
scope
:note_hooks
,
->
{
where
(
note_events:
true
,
active:
true
)
}
scope
:build_hooks
,
->
{
where
(
build_events:
true
,
active:
true
)
}
scope
:pipeline_hooks
,
->
{
where
(
pipeline_events:
true
,
active:
true
)
}
scope
:wiki_page_hooks
,
->
{
where
(
wiki_page_events:
true
,
active:
true
)
}
scope
:external_issue_trackers
,
->
{
issue_trackers
.
active
.
without_defaults
}
...
...
db/migrate/20160728081025_add_pipeline_events_to_web_hooks.rb
0 → 100644
View file @
ae5f124e
class
AddPipelineEventsToWebHooks
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
(
:web_hooks
,
:pipeline_events
,
:boolean
,
default:
false
,
allow_null:
false
)
end
def
down
remove_column
(
:web_hooks
,
:pipeline_events
)
end
end
db/migrate/20160728103734_add_pipeline_events_to_services.rb
0 → 100644
View file @
ae5f124e
class
AddPipelineEventsToServices
<
ActiveRecord
::
Migration
include
Gitlab
::
Database
::
MigrationHelpers
DOWNTIME
=
false
disable_ddl_transaction!
def
up
add_column_with_default
(
:services
,
:pipeline_events
,
:boolean
,
default:
false
,
allow_null:
false
)
end
def
down
remove_column
(
:services
,
:pipeline_events
)
end
end
lib/gitlab/data_builder/pipeline_data_builder.rb
0 → 100644
View file @
ae5f124e
module
Gitlab
module
DataBuilder
module
PipelineDataBuilder
module_function
def
build
(
pipeline
)
{
object_kind:
'pipeline'
,
user:
pipeline
.
user
.
hook_attrs
,
project:
pipeline
.
project
.
hook_attrs
(
backward:
false
),
commit:
pipeline
.
commit
.
hook_attrs
,
object_attributes:
hook_attrs
(
pipeline
),
builds:
pipeline
.
builds
.
map
(
&
method
(
:build_hook_attrs
))
}
end
def
hook_attrs
(
pipeline
)
first_pending_build
=
pipeline
.
builds
.
first_pending
config_processor
=
pipeline
.
config_processor
{
id:
pipeline
.
id
,
ref:
pipeline
.
ref
,
tag:
pipeline
.
tag
,
sha:
pipeline
.
sha
,
before_sha:
pipeline
.
before_sha
,
status:
pipeline
.
status
,
stage:
first_pending_build
.
try
(
:stage
),
stages:
config_processor
.
try
(
:stages
),
created_at:
pipeline
.
created_at
,
finished_at:
pipeline
.
finished_at
}
end
def
build_hook_attrs
(
build
)
{
id:
build
.
id
,
stage:
build
.
stage
,
name:
build
.
name
,
status:
build
.
status
,
created_at:
build
.
created_at
,
started_at:
build
.
started_at
,
finished_at:
build
.
finished_at
,
when:
build
.
when
,
manual:
build
.
manual?
,
user:
build
.
user
.
hook_attrs
,
runner:
runner_hook_attrs
(
build
.
runner
),
artifacts_file:
{
filename:
build
.
artifacts_file
.
filename
,
size:
build
.
artifacts_size
}
}
end
def
runner_hook_attrs
(
runner
)
{
id:
runner
.
id
,
description:
runner
.
description
,
active:
runner
.
active?
,
is_shared:
runner
.
is_shared?
}
end
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