2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module Groups
|
|
|
|
module Settings
|
|
|
|
class CiCdController < Groups::ApplicationController
|
2018-03-27 19:54:05 +05:30
|
|
|
skip_cross_project_access_check :show
|
2019-01-03 12:48:30 +05:30
|
|
|
before_action :authorize_admin_group!
|
2017-09-10 17:25:29 +05:30
|
|
|
|
|
|
|
def show
|
2018-12-13 13:39:08 +05:30
|
|
|
define_ci_variables
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
def reset_registration_token
|
|
|
|
@group.reset_runners_token!
|
|
|
|
|
2019-05-18 00:54:41 +05:30
|
|
|
flash[:notice] = _('GroupSettings|New runners registration token has been generated!')
|
|
|
|
redirect_to group_settings_ci_cd_path
|
|
|
|
end
|
|
|
|
|
|
|
|
def update_auto_devops
|
|
|
|
if auto_devops_service.execute
|
|
|
|
flash[:notice] = s_('GroupSettings|Auto DevOps pipeline was updated for the group')
|
|
|
|
else
|
|
|
|
flash[:alert] = s_("GroupSettings|There was a problem updating Auto DevOps pipeline: %{error_messages}." % { error_messages: group.errors.full_messages })
|
|
|
|
end
|
|
|
|
|
2018-12-05 23:21:45 +05:30
|
|
|
redirect_to group_settings_ci_cd_path
|
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
private
|
|
|
|
|
2018-12-13 13:39:08 +05:30
|
|
|
def define_ci_variables
|
2017-09-10 17:25:29 +05:30
|
|
|
@variable = Ci::GroupVariable.new(group: group)
|
|
|
|
.present(current_user: current_user)
|
|
|
|
@variables = group.variables.order_key_asc
|
|
|
|
.map { |variable| variable.present(current_user: current_user) }
|
|
|
|
end
|
|
|
|
|
2019-01-03 12:48:30 +05:30
|
|
|
def authorize_admin_group!
|
|
|
|
return render_404 unless can?(current_user, :admin_group, group)
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
2019-05-18 00:54:41 +05:30
|
|
|
|
|
|
|
def auto_devops_params
|
|
|
|
params.require(:group).permit(:auto_devops_enabled)
|
|
|
|
end
|
|
|
|
|
|
|
|
def auto_devops_service
|
|
|
|
Groups::AutoDevopsService.new(group, current_user, auto_devops_params)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|