Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
63bf2457
Commit
63bf2457
authored
Jul 04, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Follow feedback on the merge request
parent
d7c32c58
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
41 additions
and
40 deletions
+41
-40
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+4
-12
app/models/project.rb
app/models/project.rb
+8
-0
app/models/repository.rb
app/models/repository.rb
+2
-2
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+2
-23
spec/models/project_spec.rb
spec/models/project_spec.rb
+24
-0
spec/support/cycle_analytics_helpers.rb
spec/support/cycle_analytics_helpers.rb
+1
-3
No files found.
app/models/ci/pipeline.rb
View file @
63bf2457
...
...
@@ -330,10 +330,10 @@ module Ci
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
@ci_yaml_file
=
begin
project
.
repository
.
gitlab_ci_yml_for
(
sha
,
ci_yaml_file_path
)
rescue
project
.
repository
.
gitlab_ci_yml_for
(
sha
)
rescue
Rugged
::
ReferenceError
,
GRPC
::
NotFound
self
.
yaml_errors
=
"Failed to load CI/CD config file at
#{
ci_yaml_file_path
}
"
"Failed to load CI/CD config file at
#{
project
.
ci_config_file_for_pipeline
}
"
nil
end
end
...
...
@@ -342,14 +342,6 @@ module Ci
yaml_errors
.
present?
end
def
ci_yaml_file_path
if
project
.
ci_config_file
.
blank?
'.gitlab-ci.yml'
else
project
.
ci_config_file
end
end
def
environments
builds
.
where
.
not
(
environment:
nil
).
success
.
pluck
(
:environment
).
uniq
end
...
...
@@ -392,7 +384,7 @@ module Ci
def
predefined_variables
[
{
key:
'CI_PIPELINE_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
ci_yaml_file_path
,
public:
true
}
{
key:
'CI_CONFIG_PATH'
,
value:
project
.
ci_config_file_for_pipeline
,
public:
true
}
]
end
...
...
app/models/project.rb
View file @
63bf2457
...
...
@@ -526,6 +526,14 @@ class Project < ActiveRecord::Base
import_data
&
.
destroy
end
def
ci_config_file_for_pipeline
if
ci_config_file
.
blank?
'.gitlab-ci.yml'
else
ci_config_file
end
end
def
ci_config_file
=
(
value
)
# Strip all leading slashes so that //foo -> foo
super
(
value
&
.
sub
(
%r{
\A
/+}
,
''
))
...
...
app/models/repository.rb
View file @
63bf2457
...
...
@@ -1078,8 +1078,8 @@ class Repository
blob_data_at
(
sha
,
'.gitlab/route-map.yml'
)
end
def
gitlab_ci_yml_for
(
sha
,
path
=
'.gitlab-ci.yml'
)
blob_data_at
(
sha
,
p
ath
)
def
gitlab_ci_yml_for
(
sha
)
blob_data_at
(
sha
,
p
roject
.
ci_config_file_for_pipeline
)
end
private
...
...
spec/models/ci/pipeline_spec.rb
View file @
63bf2457
...
...
@@ -748,30 +748,9 @@ describe Ci::Pipeline, models: true do
end
end
describe
'#ci_yaml_file_path'
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:pipeline
)
{
create
(
:ci_empty_pipeline
,
project:
project
)
}
it
'returns the path from project'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
'custom/path'
}
expect
(
pipeline
.
ci_yaml_file_path
).
to
eq
(
'custom/path'
)
end
it
'returns default when custom path is nil'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
nil
}
expect
(
pipeline
.
ci_yaml_file_path
).
to
eq
(
'.gitlab-ci.yml'
)
end
it
'returns default when custom path is empty'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
''
}
expect
(
pipeline
.
ci_yaml_file_path
).
to
eq
(
'.gitlab-ci.yml'
)
end
describe
'#ci_yaml_file'
do
it
'reports error if the file is not found'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
'custom'
}
allow
(
p
ipeline
.
p
roject
).
to
receive
(
:ci_config_file
)
{
'custom'
}
pipeline
.
ci_yaml_file
...
...
spec/models/project_spec.rb
View file @
63bf2457
...
...
@@ -1493,6 +1493,30 @@ describe Project, models: true do
end
end
describe
'#ci_config_file_for_pipeline'
do
let
(
:project
)
{
create
(
:empty_project
)
}
subject
{
project
.
ci_config_file_for_pipeline
}
it
'returns the path from project'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
'custom/path'
}
is_expected
.
to
eq
(
'custom/path'
)
end
it
'returns default when custom path is nil'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
nil
}
is_expected
.
to
eq
(
'.gitlab-ci.yml'
)
end
it
'returns default when custom path is empty'
do
allow
(
project
).
to
receive
(
:ci_config_file
)
{
''
}
is_expected
.
to
eq
(
'.gitlab-ci.yml'
)
end
end
describe
'#ci_config_file='
do
let
(
:project
)
{
create
(
:empty_project
)
}
...
...
spec/support/cycle_analytics_helpers.rb
View file @
63bf2457
...
...
@@ -74,9 +74,7 @@ module CycleAnalyticsHelpers
def
dummy_pipeline
@dummy_pipeline
||=
Ci
::
Pipeline
.
new
(
sha:
project
.
repository
.
commit
(
'master'
).
sha
,
project:
project
)
project
.
pipelines
.
build
(
sha:
project
.
repository
.
commit
(
'master'
).
sha
)
end
def
new_dummy_job
(
environment
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment