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
Boxiang Sun
gitlab-ce
Commits
c288ca78
Commit
c288ca78
authored
Sep 06, 2017
by
Zeger-Jan van de Weg
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use hook for setting Pipeline config_source
parent
003bfac2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
32 additions
and
20 deletions
+32
-20
app/models/ci/pipeline.rb
app/models/ci/pipeline.rb
+14
-7
app/models/project.rb
app/models/project.rb
+11
-6
app/models/project_auto_devops.rb
app/models/project_auto_devops.rb
+1
-1
app/serializers/pipeline_entity.rb
app/serializers/pipeline_entity.rb
+1
-1
app/services/ci/create_pipeline_service.rb
app/services/ci/create_pipeline_service.rb
+4
-4
spec/services/ci/create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+1
-1
No files found.
app/models/ci/pipeline.rb
View file @
c288ca78
...
...
@@ -38,6 +38,7 @@ module Ci
validates
:status
,
presence:
{
unless: :importing?
}
validate
:valid_commit_sha
,
unless: :importing?
after_initialize
:set_config_source
,
if: :new_record?
after_create
:keep_around_commits
,
unless: :importing?
enum
source:
{
...
...
@@ -318,9 +319,16 @@ module Ci
builds
.
latest
.
failed_but_allowed
.
any?
end
def
detect_ci_yaml_file
ci_yaml_from_repo
&
.
tap
{
self
.
repository_source!
}
||
implied_ci_yaml_file
&
.
tap
{
self
.
auto_devops_source!
}
def
set_config_source
self
.
config_source
=
if
project
case
when
ci_yaml_from_repo
then
:repository_source
when
implied_ci_yaml_file
then
:auto_devops_source
end
else
:unknown_source
end
end
def
config_processor
...
...
@@ -350,11 +358,10 @@ module Ci
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
@ci_yaml_file
=
case
config_source
when
"repository_source"
,
"unknown_source"
ci_yaml_from_repo
when
"auto_devops_source"
if
auto_devops_source?
implied_ci_yaml_file
else
ci_yaml_from_repo
end
if
@ci_yaml_file
...
...
app/models/project.rb
View file @
c288ca78
...
...
@@ -469,10 +469,10 @@ class Project < ActiveRecord::Base
end
def
auto_devops_enabled?
if
auto_devops
&&
auto_devops
.
enabled
.
present?
auto_devops
.
enabled?
else
if
auto_devops
&
.
enabled
.
nil?
current_application_settings
.
auto_devops_enabled?
else
auto_devops
.
enabled?
end
end
...
...
@@ -1389,15 +1389,20 @@ class Project < ActiveRecord::Base
end
def
predefined_variables
[
variables
=
[
{
key:
'CI_PROJECT_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_PROJECT_NAME'
,
value:
path
,
public:
true
},
{
key:
'CI_PROJECT_PATH'
,
value:
full_path
,
public:
true
},
{
key:
'CI_PROJECT_PATH_SLUG'
,
value:
full_path_slug
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
web_url
,
public:
true
},
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
auto_devops
.
domain
,
public:
true
}
{
key:
'CI_PROJECT_URL'
,
value:
web_url
,
public:
true
}
]
if
auto_devops_enabled?
&&
auto_devops
&
.
domain
variables
<<
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
auto_devops
.
domain
,
public:
true
}
end
variables
end
def
container_registry_variables
...
...
app/models/project_auto_devops.rb
View file @
c288ca78
class
ProjectAutoDevops
<
ActiveRecord
::
Base
belongs_to
:project
validates
:domain
,
presence:
true
,
if: :enabled?
validates
:domain
,
presence:
true
,
hostname:
{
allow_numeric_hostname:
true
},
if: :enabled?
end
app/serializers/pipeline_entity.rb
View file @
c288ca78
...
...
@@ -16,7 +16,7 @@ class PipelineEntity < Grape::Entity
expose
:flags
do
expose
:latest?
,
as: :latest
expose
:stuck?
,
as: :stuck
expose
:auto_devops?
,
as: :auto_devops
expose
:auto_devops
_source
?
,
as: :auto_devops
expose
:has_yaml_errors?
,
as: :yaml_errors
expose
:can_retry?
,
as: :retryable
expose
:can_cancel?
,
as: :cancelable
...
...
app/services/ci/create_pipeline_service.rb
View file @
c288ca78
...
...
@@ -67,11 +67,11 @@ module Ci
return
error
(
'Commit not found'
)
end
unless
pipeline
.
detect_ci_yaml_file
unless
pipeline
.
config_processor
unless
pipeline
.
ci_yaml_file
return
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
end
unless
pipeline
.
config_processor
return
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
c288ca78
require
'spec_helper'
describe
Ci
::
CreatePipelineService
do
l
et
(
:project
)
{
create
(
:project
,
:repository
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:admin
)
}
let
(
:ref_name
)
{
'refs/heads/master'
}
...
...
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