summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKatarzyna Kobierska <kkobierska@gmail.com>2016-09-20 15:19:55 +0200
committerKatarzyna Kobierska <kkobierska@gmail.com>2016-09-30 12:22:55 +0200
commit7dfb204ef9d343888e2fd8327c5a5348b98a76ce (patch)
tree35d1760ca664f9e9a029516eaef7b459a4b7aa84
parente26953bc4bc7c9522258f201b175c60fd6c0b2a2 (diff)
downloadgitlab-ce-7dfb204ef9d343888e2fd8327c5a5348b98a76ce.tar.gz
Expose jobs to view
-rw-r--r--app/controllers/ci/lints_controller.rb1
-rw-r--r--app/services/ci/create_pipeline_builds_service.rb6
-rw-r--r--app/views/ci/lints/_create.html.haml6
-rw-r--r--lib/ci/gitlab_ci_yaml_processor.rb4
-rw-r--r--spec/lib/ci/gitlab_ci_yaml_processor_spec.rb28
-rw-r--r--spec/views/ci/lints/show.html.haml_spec.rb16
6 files changed, 28 insertions, 33 deletions
diff --git a/app/controllers/ci/lints_controller.rb b/app/controllers/ci/lints_controller.rb
index e06d12cfce1..78012960252 100644
--- a/app/controllers/ci/lints_controller.rb
+++ b/app/controllers/ci/lints_controller.rb
@@ -14,6 +14,7 @@ module Ci
@config_processor = Ci::GitlabCiYamlProcessor.new(@content)
@stages = @config_processor.stages
@builds = @config_processor.builds
+ @jobs = @config_processor.jobs
end
rescue
@error = 'Undefined error'
diff --git a/app/services/ci/create_pipeline_builds_service.rb b/app/services/ci/create_pipeline_builds_service.rb
index 3fc707b1e14..005014fa1de 100644
--- a/app/services/ci/create_pipeline_builds_service.rb
+++ b/app/services/ci/create_pipeline_builds_service.rb
@@ -13,11 +13,6 @@ module Ci
private
def create_build(build_attributes)
- build_attributes = build_attributes.slice(
- :stage_idx, :stage, :commands, :tag_list, :name, :when, :allow_failure,
- :environment, :yaml_variables, :options
- )
-
build_attributes = build_attributes.merge(
pipeline: pipeline,
project: pipeline.project,
@@ -26,7 +21,6 @@ module Ci
user: current_user,
trigger_request: trigger_request
)
-
pipeline.builds.create(build_attributes)
end
diff --git a/app/views/ci/lints/_create.html.haml b/app/views/ci/lints/_create.html.haml
index 733c5d0b7fe..342259226a2 100644
--- a/app/views/ci/lints/_create.html.haml
+++ b/app/views/ci/lints/_create.html.haml
@@ -21,13 +21,13 @@
%br
%b Tag list:
- = build[:tag_list] && build[:tag_list].join(", ")
+ = build[:tag_list] && build[:tag_list].to_a.join(", ")
%br
%b Refs only:
- = build[:only] && build[:only].join(", ")
+ = @jobs[build[:name].to_sym][:only] && @jobs[build[:name].to_sym][:only].to_a.join(", ")
%br
%b Refs except:
- = build[:except] && build[:except].join(", ")
+ = @jobs[build[:name].to_sym][:except] && @jobs[build[:name].to_sym][:except].to_a.join(", ")
%br
%b Environment:
= build[:environment]
diff --git a/lib/ci/gitlab_ci_yaml_processor.rb b/lib/ci/gitlab_ci_yaml_processor.rb
index b61388d6ea7..2fd1fced65c 100644
--- a/lib/ci/gitlab_ci_yaml_processor.rb
+++ b/lib/ci/gitlab_ci_yaml_processor.rb
@@ -4,7 +4,7 @@ module Ci
include Gitlab::Ci::Config::Node::LegacyValidationHelpers
- attr_reader :path, :cache, :stages
+ attr_reader :path, :cache, :stages, :jobs
def initialize(config, path = nil)
@ci_config = Gitlab::Ci::Config.new(config)
@@ -59,8 +59,6 @@ module Ci
tag_list: job[:tags] || [],
name: job[:name].to_s,
allow_failure: job[:allow_failure] || false,
- only: job[:only],
- except: job[:except],
when: job[:when] || 'on_success',
environment: job[:environment_name],
yaml_variables: yaml_variables(name),
diff --git a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
index 317259f0c27..6dedd25e9d3 100644
--- a/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+++ b/spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
@@ -26,9 +26,7 @@ module Ci
allow_failure: false,
when: "on_success",
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
@@ -445,9 +443,7 @@ module Ci
allow_failure: false,
when: "on_success",
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
@@ -475,9 +471,7 @@ module Ci
allow_failure: false,
when: "on_success",
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
end
@@ -722,9 +716,7 @@ module Ci
when: "on_success",
allow_failure: false,
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
@@ -867,9 +859,7 @@ module Ci
when: "on_success",
allow_failure: false,
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
end
@@ -914,9 +904,7 @@ module Ci
when: "on_success",
allow_failure: false,
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
expect(subject.second).to eq({
stage: "build",
@@ -928,9 +916,7 @@ module Ci
when: "on_success",
allow_failure: false,
environment: nil,
- yaml_variables: [],
- only: nil,
- except: nil
+ yaml_variables: []
})
end
end
diff --git a/spec/views/ci/lints/show.html.haml_spec.rb b/spec/views/ci/lints/show.html.haml_spec.rb
index be41134d12a..620fb0e4821 100644
--- a/spec/views/ci/lints/show.html.haml_spec.rb
+++ b/spec/views/ci/lints/show.html.haml_spec.rb
@@ -20,6 +20,7 @@ describe 'ci/lints/show' do
assign(:status, true)
assign(:builds, config_processor.builds)
assign(:stages, config_processor.stages)
+ assign(:jobs, config_processor.jobs)
end
it 'shows the correct values' do
@@ -32,4 +33,19 @@ describe 'ci/lints/show' do
expect(rendered).to have_content('When: on_success')
end
end
+
+ context 'when the content is invalid' do
+ before do
+ assign(:status, false)
+ assign(:error, 'Undefined error')
+ end
+
+ it 'shows error message' do
+ render
+
+ expect(rendered).to have_content('Status: syntax is incorrec')
+ expect(rendered).to have_content('Error: Undefined error')
+ expect(rendered).not_to have_content('Tag list:')
+ end
+ end
end