debian-mirror-gitlab/app/models/project_services/gemnasium_service.rb

61 lines
1.5 KiB
Ruby
Raw Normal View History

2014-09-02 18:07:02 +05:30
require "gemnasium/gitlab_service"
class GemnasiumService < Service
2015-04-26 12:48:37 +05:30
prop_accessor :token, :api_key
2014-09-02 18:07:02 +05:30
validates :token, :api_key, presence: true, if: :activated?
2018-11-08 19:23:39 +05:30
validate :deprecation_validation
2014-09-02 18:07:02 +05:30
def title
'Gemnasium'
end
def description
'Gemnasium monitors your project dependencies and alerts you about updates and security vulnerabilities.'
end
2017-08-17 22:00:37 +05:30
def self.to_param
2014-09-02 18:07:02 +05:30
'gemnasium'
end
def fields
[
2017-09-10 17:25:29 +05:30
{ type: 'text', name: 'api_key', placeholder: 'Your personal API KEY on gemnasium.com ', required: true },
{ type: 'text', name: 'token', placeholder: 'The project\'s slug on gemnasium.com', required: true }
2014-09-02 18:07:02 +05:30
]
end
2017-08-17 22:00:37 +05:30
def self.supported_events
2015-04-26 12:48:37 +05:30
%w(push)
end
2018-11-08 19:23:39 +05:30
def deprecated?
true
end
def deprecation_message
"Gemnasium has been acquired by GitLab in January 2018. Since May 15, 2018, the service provided by Gemnasium is no longer available."
end
def deprecation_validation
errors[:base] << deprecation_message
end
2015-04-26 12:48:37 +05:30
def execute(data)
return unless supported_events.include?(data[:object_kind])
2018-11-08 19:23:39 +05:30
# Gitaly: this class will be removed https://gitlab.com/gitlab-org/gitlab-ee/issues/6010
repo_path = Gitlab::GitalyClient::StorageSettings.allow_disk_access do
project.repository.path_to_repo
end
2014-09-02 18:07:02 +05:30
Gemnasium::GitlabService.execute(
2015-04-26 12:48:37 +05:30
ref: data[:ref],
before: data[:before],
after: data[:after],
2014-09-02 18:07:02 +05:30
token: token,
api_key: api_key,
2018-11-08 19:23:39 +05:30
repo: repo_path
2015-12-23 02:04:40 +05:30
)
2014-09-02 18:07:02 +05:30
end
end