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
...
@@ -38,6 +38,7 @@ module Ci
validates
:status
,
presence:
{
unless: :importing?
}
validates
:status
,
presence:
{
unless: :importing?
}
validate
:valid_commit_sha
,
unless: :importing?
validate
:valid_commit_sha
,
unless: :importing?
after_initialize
:set_config_source
,
if: :new_record?
after_create
:keep_around_commits
,
unless: :importing?
after_create
:keep_around_commits
,
unless: :importing?
enum
source:
{
enum
source:
{
...
@@ -318,9 +319,16 @@ module Ci
...
@@ -318,9 +319,16 @@ module Ci
builds
.
latest
.
failed_but_allowed
.
any?
builds
.
latest
.
failed_but_allowed
.
any?
end
end
def
detect_ci_yaml_file
def
set_config_source
ci_yaml_from_repo
&
.
tap
{
self
.
repository_source!
}
||
self
.
config_source
=
implied_ci_yaml_file
&
.
tap
{
self
.
auto_devops_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
end
def
config_processor
def
config_processor
...
@@ -350,11 +358,10 @@ module Ci
...
@@ -350,11 +358,10 @@ module Ci
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
return
@ci_yaml_file
if
defined?
(
@ci_yaml_file
)
@ci_yaml_file
=
@ci_yaml_file
=
case
config_source
if
auto_devops_source?
when
"repository_source"
,
"unknown_source"
ci_yaml_from_repo
when
"auto_devops_source"
implied_ci_yaml_file
implied_ci_yaml_file
else
ci_yaml_from_repo
end
end
if
@ci_yaml_file
if
@ci_yaml_file
...
...
app/models/project.rb
View file @
c288ca78
...
@@ -469,10 +469,10 @@ class Project < ActiveRecord::Base
...
@@ -469,10 +469,10 @@ class Project < ActiveRecord::Base
end
end
def
auto_devops_enabled?
def
auto_devops_enabled?
if
auto_devops
&&
auto_devops
.
enabled
.
present?
if
auto_devops
&
.
enabled
.
nil?
auto_devops
.
enabled?
else
current_application_settings
.
auto_devops_enabled?
current_application_settings
.
auto_devops_enabled?
else
auto_devops
.
enabled?
end
end
end
end
...
@@ -1389,15 +1389,20 @@ class Project < ActiveRecord::Base
...
@@ -1389,15 +1389,20 @@ class Project < ActiveRecord::Base
end
end
def
predefined_variables
def
predefined_variables
[
variables
=
[
{
key:
'CI_PROJECT_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_PROJECT_ID'
,
value:
id
.
to_s
,
public:
true
},
{
key:
'CI_PROJECT_NAME'
,
value:
path
,
public:
true
},
{
key:
'CI_PROJECT_NAME'
,
value:
path
,
public:
true
},
{
key:
'CI_PROJECT_PATH'
,
value:
full_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_PATH_SLUG'
,
value:
full_path_slug
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_NAMESPACE'
,
value:
namespace
.
full_path
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
web_url
,
public:
true
},
{
key:
'CI_PROJECT_URL'
,
value:
web_url
,
public:
true
}
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
auto_devops
.
domain
,
public:
true
}
]
]
if
auto_devops_enabled?
&&
auto_devops
&
.
domain
variables
<<
{
key:
'AUTO_DEVOPS_DOMAIN'
,
value:
auto_devops
.
domain
,
public:
true
}
end
variables
end
end
def
container_registry_variables
def
container_registry_variables
...
...
app/models/project_auto_devops.rb
View file @
c288ca78
class
ProjectAutoDevops
<
ActiveRecord
::
Base
class
ProjectAutoDevops
<
ActiveRecord
::
Base
belongs_to
:project
belongs_to
:project
validates
:domain
,
presence:
true
,
if: :enabled?
validates
:domain
,
presence:
true
,
hostname:
{
allow_numeric_hostname:
true
},
if: :enabled?
end
end
app/serializers/pipeline_entity.rb
View file @
c288ca78
...
@@ -16,7 +16,7 @@ class PipelineEntity < Grape::Entity
...
@@ -16,7 +16,7 @@ class PipelineEntity < Grape::Entity
expose
:flags
do
expose
:flags
do
expose
:latest?
,
as: :latest
expose
:latest?
,
as: :latest
expose
:stuck?
,
as: :stuck
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
:has_yaml_errors?
,
as: :yaml_errors
expose
:can_retry?
,
as: :retryable
expose
:can_retry?
,
as: :retryable
expose
:can_cancel?
,
as: :cancelable
expose
:can_cancel?
,
as: :cancelable
...
...
app/services/ci/create_pipeline_service.rb
View file @
c288ca78
...
@@ -67,11 +67,11 @@ module Ci
...
@@ -67,11 +67,11 @@ module Ci
return
error
(
'Commit not found'
)
return
error
(
'Commit not found'
)
end
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"
)
return
error
(
"Missing
#{
pipeline
.
ci_yaml_file_path
}
file"
)
end
end
unless
pipeline
.
config_processor
return
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
return
error
(
pipeline
.
yaml_errors
,
save:
save_on_errors
)
end
end
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
c288ca78
require
'spec_helper'
require
'spec_helper'
describe
Ci
::
CreatePipelineService
do
describe
Ci
::
CreatePipelineService
do
l
et
(
:project
)
{
create
(
:project
,
:repository
)
}
s
et
(
:project
)
{
create
(
:project
,
:repository
)
}
let
(
:user
)
{
create
(
:admin
)
}
let
(
:user
)
{
create
(
:admin
)
}
let
(
:ref_name
)
{
'refs/heads/master'
}
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