-
Notifications
You must be signed in to change notification settings - Fork 81
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
74 changed files
with
2,084 additions
and
427 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,7 @@ | ||
# exclude Jenkins work files | ||
pkg | ||
work | ||
|
||
# exclude Idea files | ||
.idea | ||
*.iml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
require 'sinatra/base' | ||
|
||
require_relative 'exceptions/bad_request_exception' | ||
require_relative 'exceptions/configuration_exception' | ||
require_relative 'exceptions/not_found_exception' | ||
require_relative 'use_cases/process_commit' | ||
require_relative 'use_cases/process_delete_commit' | ||
require_relative 'services/parse_request' | ||
|
||
include Java | ||
|
||
java_import Java.java.util.logging.Logger | ||
java_import Java.java.util.logging.Level | ||
|
||
module GitlabWebHook | ||
class Api < Sinatra::Base | ||
LOGGER = Logger.getLogger(Api.class.name) | ||
|
||
get '/ping' do | ||
'Gitlab Web Hook is up and running :-)' | ||
end | ||
|
||
notify_commit = lambda do | ||
process_projects Proc.new { |project| NotifyCommit.new(project).call } | ||
end | ||
get '/notify_commit', ¬ify_commit | ||
post '/notify_commit', ¬ify_commit | ||
|
||
build_now = lambda do | ||
process_projects Proc.new { |project, details| BuildNow.new(project).with(details) } | ||
end | ||
get '/build_now', &build_now | ||
post '/build_now', &build_now | ||
|
||
private | ||
|
||
def process_projects(action) | ||
details = parse_request | ||
messages = details.is_delete_branch_commit? ? ProcessDeleteCommit.new.with(details) : ProcessCommit.new.with(details, action) | ||
LOGGER.info(messages.join("\n")) | ||
messages.join("<br/>") | ||
rescue BadRequestException => e | ||
LOGGER.warning(e.message) | ||
status 400 | ||
e.message | ||
rescue NotFoundException => e | ||
LOGGER.warning(e.message) | ||
status 404 | ||
e.message | ||
rescue => e | ||
LOGGER.log(Level::SEVERE, e.message, e) | ||
status 500 | ||
e.message | ||
end | ||
|
||
def parse_request | ||
details = ParseRequest.new.from(params, request) | ||
LOGGER.info("gitlab web hook triggered for repo url #{details.repository_url} and #{details.branch} branch") | ||
LOGGER.info("with payload: #{details.payload}") | ||
details | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module GitlabWebHook | ||
class BadRequestException < StandardError | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module GitlabWebHook | ||
class ConfigurationException < StandardError | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
module GitlabWebHook | ||
class NotFoundException < StandardError | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.