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
489e9be4
Commit
489e9be4
authored
Jul 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add CI job script node in new config processor
parent
3c5b1da2
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
92 additions
and
8 deletions
+92
-8
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+7
-3
lib/gitlab/ci/config/node/job_script.rb
lib/gitlab/ci/config/node/job_script.rb
+31
-0
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+2
-2
spec/lib/gitlab/ci/config/node/job_script_spec.rb
spec/lib/gitlab/ci/config/node/job_script_spec.rb
+49
-0
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+2
-2
No files found.
lib/gitlab/ci/config/node/job.rb
View file @
489e9be4
...
@@ -15,13 +15,16 @@ module Gitlab
...
@@ -15,13 +15,16 @@ module Gitlab
node
:before_script
,
Script
,
node
:before_script
,
Script
,
description:
'Global before script overridden in this job.'
description:
'Global before script overridden in this job.'
node
:script
,
JobScript
,
description:
'Commands that will be executed in this job.'
node
:stage
,
Stage
,
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
description:
'Pipeline stage this job will be executed into.'
node
:type
,
Stage
,
node
:type
,
Stage
,
description:
'Deprecated: stage this job will be executed into.'
description:
'Deprecated: stage this job will be executed into.'
helpers
:before_script
,
:stage
,
:type
helpers
:before_script
,
:s
cript
,
:s
tage
,
:type
def
value
def
value
raise
InvalidError
unless
valid?
raise
InvalidError
unless
valid?
...
@@ -36,8 +39,9 @@ module Gitlab
...
@@ -36,8 +39,9 @@ module Gitlab
private
private
def
to_hash
def
to_hash
{
before_script:
before_script
,
{
before_script:
before_script_value
,
stage:
stage
}
script:
script_value
,
stage:
stage_value
}
end
end
def
compose!
def
compose!
...
...
lib/gitlab/ci/config/node/job_script.rb
0 → 100644
View file @
489e9be4
module
Gitlab
module
Ci
class
Config
module
Node
##
# Entry that represents a job script.
#
class
JobScript
<
Entry
include
Validatable
validations
do
include
LegacyValidationHelpers
validate
:string_or_array_of_strings
def
string_or_array_of_strings
unless
validate_string
(
config
)
||
validate_array_of_strings
(
config
)
errors
.
add
(
:config
,
'should be a string or an array of strings'
)
end
end
end
def
value
[
@config
].
flatten
end
end
end
end
end
end
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
489e9be4
...
@@ -129,8 +129,8 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -129,8 +129,8 @@ describe Gitlab::Ci::Config::Node::Global do
describe
'#jobs'
do
describe
'#jobs'
do
it
'returns jobs configuration'
do
it
'returns jobs configuration'
do
expect
(
global
.
jobs
)
expect
(
global
.
jobs
)
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_script_spec.rb
0 → 100644
View file @
489e9be4
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
JobScript
do
let
(
:entry
)
{
described_class
.
new
(
config
)
}
context
'when entry config value is an array'
do
let
(
:config
)
{
[
'ls'
,
'pwd'
]
}
describe
'#value'
do
it
'returns array of strings'
do
expect
(
entry
.
value
).
to
eq
config
end
end
describe
'#errors'
do
it
'does not append errors'
do
expect
(
entry
.
errors
).
to
be_empty
end
end
end
context
'when entry config value is a string'
do
let
(
:config
)
{
'ls'
}
describe
'#value'
do
it
'returns array with single element'
do
expect
(
entry
.
value
).
to
eq
[
'ls'
]
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
end
end
end
context
'when entry value is not valid'
do
let
(
:config
)
{
1
}
describe
'#errors'
do
it
'saves errors'
do
expect
(
entry
.
errors
)
.
to
include
'job script config should be a '
\
'string or an array of strings'
end
end
end
end
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
489e9be4
...
@@ -54,7 +54,7 @@ describe Gitlab::Ci::Config::Node::Job do
...
@@ -54,7 +54,7 @@ describe Gitlab::Ci::Config::Node::Job do
it
'returns correct value'
do
it
'returns correct value'
do
expect
(
entry
.
value
)
expect
(
entry
.
value
)
.
to
eq
(
before_script:
%w[ls pwd]
,
.
to
eq
(
before_script:
%w[ls pwd]
,
script:
'rspec'
,
script:
%w[rspec]
,
stage:
'test'
)
stage:
'test'
)
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
489e9be4
...
@@ -62,8 +62,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
...
@@ -62,8 +62,8 @@ describe Gitlab::Ci::Config::Node::Jobs do
describe
'#value'
do
describe
'#value'
do
it
'returns key value'
do
it
'returns key value'
do
expect
(
entry
.
value
)
expect
(
entry
.
value
)
.
to
eq
(
rspec:
{
script:
'rspec'
,
stage:
'test'
},
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
stage:
'test'
},
spinach:
{
script:
'spinach'
,
stage:
'test'
})
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
end
end
end
end
...
...
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