Commit 679667d6 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce

parents 096bb561 ada95df8
......@@ -14,6 +14,7 @@ v 8.1.0 (unreleased)
- Add notes and SSL verification entries to hook APIs (Ben Boeckel)
- Fix grammar in admin area "labels" .nothing-here-block when no labels exist.
- Move CI runners page to project settings area
- Move CI variables page to project settings area
v 8.0.3
- Fix URL shown in Slack notifications
......
module Ci
class VariablesController < Ci::ApplicationController
before_action :authenticate_user!
before_action :project
before_action :authorize_access_project!
before_action :authorize_manage_project!
layout 'ci/project'
def show
end
def update
if project.update_attributes(project_params)
Ci::EventService.new.change_project_settings(current_user, project)
redirect_to ci_project_variables_path(project), notice: 'Variables were successfully updated.'
else
render action: 'show'
end
end
private
def project
@project ||= Ci::Project.find(params[:project_id])
end
def project_params
params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] })
end
end
end
......@@ -31,4 +31,8 @@ class Projects::ApplicationController < ApplicationController
def ci_enabled
return render_404 unless @project.gitlab_ci?
end
def ci_project
@ci_project ||= @project.gitlab_ci_project
end
end
......@@ -55,10 +55,6 @@ class Projects::RunnersController < Projects::ApplicationController
protected
def ci_project
@ci_project = @project.gitlab_ci_project
end
def set_runner
@runner ||= @ci_project.runners.find(params[:id])
end
......
class Projects::VariablesController < Projects::ApplicationController
before_action :ci_project
before_action :authorize_admin_project!
layout 'project_settings'
def show
end
def update
if ci_project.update_attributes(project_params)
Ci::EventService.new.change_project_settings(current_user, ci_project)
redirect_to namespace_project_variables_path(project.namespace, project), notice: 'Variables were successfully updated.'
else
render action: 'show'
end
end
private
def project_params
params.require(:project).permit({ variables_attributes: [:id, :key, :value, :_destroy] })
end
end
module AuthHelper
PROVIDERS_WITH_ICONS = %w(twitter github gitlab bitbucket google_oauth2).freeze
FORM_BASED_PROVIDERS = [/\Aldap/, 'kerberos', 'crowd'].freeze
FORM_BASED_PROVIDERS = [/\Aldap/, 'crowd'].freeze
def ldap_enabled?
Gitlab.config.ldap.enabled
......
......@@ -11,11 +11,6 @@
%span
Commits
%span.count= @project.commits.count
= nav_link path: 'variables#show' do
= link_to ci_project_variables_path(@project) do
= icon('code fw')
%span
Variables
= nav_link path: 'web_hooks#index' do
= link_to ci_project_web_hooks_path(@project) do
= icon('link fw')
......
......@@ -40,3 +40,8 @@
= icon('cog fw')
%span
Runners
= nav_link(controller: :variables) do
= link_to namespace_project_variables_path(@project.namespace, @project) do
= icon('code fw')
%span
Variables
%h3.page-title
Secret Variables
%p.light
%p.light
These variables will be set to environment by the runner and will be hidden in the build log.
%br
So you can use them for passwords, secret keys or whatever you want.
So you can use them for passwords, secret keys or whatever you want.
%hr
= nested_form_for @project, url: url_for(controller: 'ci/variables', action: 'update'), html: { class: 'form-horizontal' } do |f|
= nested_form_for @ci_project, url: url_for(controller: 'projects/variables', action: 'update'), html: { class: 'form-horizontal' } do |f|
- if @project.errors.any?
#error_explanation
%p.lead= "#{pluralize(@project.errors.count, "error")} prohibited this project from being saved:"
%p.lead= "#{pluralize(@ci_project.errors.count, "error")} prohibited this project from being saved:"
.alert.alert-error
%ul
- @project.errors.full_messages.each do |msg|
- @ci_project.errors.full_messages.each do |msg|
%li= msg
= f.fields_for :variables do |variable_form|
......
......@@ -58,7 +58,6 @@ Gitlab::Application.routes.draw do
resources :runner_projects, only: [:create, :destroy]
resources :events, only: [:index]
resource :variables, only: [:show, :update]
end
resource :user_sessions do
......@@ -591,6 +590,7 @@ Gitlab::Application.routes.draw do
resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resources :tags, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
resource :variables, only: [:show, :update]
resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
member do
......
require 'spec_helper'
describe "Variables" do
let(:user) { create(:user) }
before do
login_as(user)
end
let(:user) { create(:user) }
before { login_as(user) }
describe "specific runners" do
before do
@project = FactoryGirl.create :ci_project
@project.gl_project.team << [user, :master]
@gl_project = @project.gl_project
@gl_project.team << [user, :master]
end
it "creates variable", js: true do
visit ci_project_variables_path(@project)
visit namespace_project_variables_path(@gl_project.namespace, @gl_project)
click_on "Add a variable"
fill_in "Key", with: "SECRET_KEY"
fill_in "Value", with: "SECRET_VALUE"
click_on "Save changes"
expect(page).to have_content("Variables were successfully updated.")
expect(@project.variables.count).to eq(1)
end
end
end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment