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
0
Merge Requests
0
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
Léo-Paul Géneau
gitlab-ce
Commits
9f7e5e45
Commit
9f7e5e45
authored
Jul 05, 2017
by
Lin Jen-Shin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add back Pipeline#ci_yaml_file_path due to all the troubles
parent
60b8156a
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
37 additions
and
39 deletions
+37
-39
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+11
-3
app/models/project.rb
app/models/project.rb
+0
-8
app/models/repository.rb
app/models/repository.rb
+2
-2
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+1
-1
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+1
-1
spec/models/ci/pipeline_spec.rb
spec/models/ci/pipeline_spec.rb
+22
-0
spec/models/project_spec.rb
spec/models/project_spec.rb
+0
-24
No files found.
app/models/ci/pipeline.rb
View file @
9f7e5e45
...
@@ -326,14 +326,22 @@ module Ci
...
@@ -326,14 +326,22 @@ module Ci
end
end
end
end
def
ci_yaml_file_path
if
project
.
ci_config_file
.
blank?
'.gitlab-ci.yml'
else
project
.
ci_config_file
end
end
def
ci_yaml_file
def
ci_yaml_file
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
@ci_yaml_file
=
begin
@ci_yaml_file
=
begin
project
.
repository
.
gitlab_ci_yml_for
(
sha
)
project
.
repository
.
gitlab_ci_yml_for
(
sha
,
ci_yaml_file_path
)
rescue
Rugged
::
ReferenceError
,
GRPC
::
NotFound
,
GRPC
::
Internal
rescue
Rugged
::
ReferenceError
,
GRPC
::
NotFound
,
GRPC
::
Internal
self
.
yaml_errors
=
self
.
yaml_errors
=
"Failed to load CI/CD config file at
#{
project
.
ci_config_file_for_pipeline
}
"
"Failed to load CI/CD config file at
#{
ci_yaml_file_path
}
"
nil
nil
end
end
end
end
...
@@ -384,7 +392,7 @@ module Ci
...
@@ -384,7 +392,7 @@ module Ci
def
predefined_variables
def
predefined_variables
[
[
{
key:
'CI_PIPELINE_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
project
.
ci_config_file_for_pipeline
,
public:
true
}
{
key:
'CI_CONFIG_PATH'
,
value:
ci_yaml_file_path
,
public:
true
}
]
]
end
end
...
...
app/models/project.rb
View file @
9f7e5e45
...
@@ -526,14 +526,6 @@ class Project < ActiveRecord::Base
...
@@ -526,14 +526,6 @@ class Project < ActiveRecord::Base
import_data
&
.
destroy
import_data
&
.
destroy
end
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
)
def
ci_config_file
=
(
value
)
# Strip all leading slashes so that //foo -> foo
# Strip all leading slashes so that //foo -> foo
super
(
value
&
.
sub
(
%r{
\A
/+}
,
''
)
&
.
delete
(
"
\0
"
))
super
(
value
&
.
sub
(
%r{
\A
/+}
,
''
)
&
.
delete
(
"
\0
"
))
...
...
app/models/repository.rb
View file @
9f7e5e45
...
@@ -1078,8 +1078,8 @@ class Repository
...
@@ -1078,8 +1078,8 @@ class Repository
blob_data_at
(
sha
,
'.gitlab/route-map.yml'
)
blob_data_at
(
sha
,
'.gitlab/route-map.yml'
)
end
end
def
gitlab_ci_yml_for
(
sha
)
def
gitlab_ci_yml_for
(
sha
,
path
=
'.gitlab-ci.yml'
)
blob_data_at
(
sha
,
p
roject
.
ci_config_file_for_pipeline
)
blob_data_at
(
sha
,
p
ath
)
end
end
private
private
...
...
app/services/ci/create_pipeline_service.rb
View file @
9f7e5e45
...
@@ -33,7 +33,7 @@ module Ci
...
@@ -33,7 +33,7 @@ module Ci
unless
pipeline
.
config_processor
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
unless
pipeline
.
ci_yaml_file
return
error
(
"Missing
#{
p
roject
.
ci_config_file_for_pipeline
}
file"
)
return
error
(
"Missing
#{
p
ipeline
.
ci_yaml_file_path
}
file"
)
end
end
return
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
return
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
end
...
...
spec/models/ci/build_spec.rb
View file @
9f7e5e45
...
@@ -1179,7 +1179,7 @@ describe Ci::Build, :models do
...
@@ -1179,7 +1179,7 @@ describe Ci::Build, :models do
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
project
.
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
project
.
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
project
.
web_url
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
.
to_s
,
public:
true
},
{
key:
'CI_PIPELINE_ID'
,
value:
pipeline
.
id
.
to_s
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
p
roject
.
ci_config_file_for_pipeline
,
public:
true
},
{
key:
'CI_CONFIG_PATH'
,
value:
p
ipeline
.
ci_yaml_file_path
,
public:
true
},
{
key:
'CI_REGISTRY_USER'
,
value:
'gitlab-ci-token'
,
public:
true
},
{
key:
'CI_REGISTRY_USER'
,
value:
'gitlab-ci-token'
,
public:
true
},
{
key:
'CI_REGISTRY_PASSWORD'
,
value:
build
.
token
,
public:
false
},
{
key:
'CI_REGISTRY_PASSWORD'
,
value:
build
.
token
,
public:
false
},
{
key:
'CI_REPOSITORY_URL'
,
value:
build
.
repo_url
,
public:
false
}
{
key:
'CI_REPOSITORY_URL'
,
value:
build
.
repo_url
,
public:
false
}
...
...
spec/models/ci/pipeline_spec.rb
View file @
9f7e5e45
...
@@ -748,6 +748,28 @@ describe Ci::Pipeline, models: true do
...
@@ -748,6 +748,28 @@ describe Ci::Pipeline, models: true do
end
end
end
end
describe
'#ci_yaml_file_path'
do
subject
{
pipeline
.
ci_yaml_file_path
}
it
'returns the path from project'
do
allow
(
pipeline
.
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
(
pipeline
.
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
(
pipeline
.
project
).
to
receive
(
:ci_config_file
)
{
''
}
is_expected
.
to
eq
(
'.gitlab-ci.yml'
)
end
end
describe
'#ci_yaml_file'
do
describe
'#ci_yaml_file'
do
it
'reports error if the file is not found'
do
it
'reports error if the file is not found'
do
allow
(
pipeline
.
project
).
to
receive
(
:ci_config_file
)
{
'custom'
}
allow
(
pipeline
.
project
).
to
receive
(
:ci_config_file
)
{
'custom'
}
...
...
spec/models/project_spec.rb
View file @
9f7e5e45
...
@@ -1493,30 +1493,6 @@ describe Project, models: true do
...
@@ -1493,30 +1493,6 @@ describe Project, models: true do
end
end
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
describe
'#ci_config_file='
do
let
(
:project
)
{
create
(
:empty_project
)
}
let
(
:project
)
{
create
(
:empty_project
)
}
...
...
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