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
Tatuya Kamada
gitlab-ce
Commits
3c5b1da2
Commit
3c5b1da2
authored
Jul 10, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add before_script node to CI job entry config
parent
24807014
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
49 additions
and
17 deletions
+49
-17
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+16
-2
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+1
-1
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+32
-14
No files found.
lib/gitlab/ci/config/node/job.rb
View file @
3c5b1da2
...
...
@@ -12,20 +12,34 @@ module Gitlab
validates
:config
,
presence:
true
end
node
:before_script
,
Script
,
description:
'Global before script overridden in this job.'
node
:stage
,
Stage
,
description:
'Pipeline stage this job will be executed into.'
node
:type
,
Stage
,
description:
'Deprecated: stage this job will be executed into.'
helpers
:stage
,
:type
helpers
:
before_script
,
:
stage
,
:type
def
value
@config
.
merge
(
stage:
stage_value
)
raise
InvalidError
unless
valid?
##
# TODO, refactoring step: do not expose internal configuration,
# return only hash value without merging it to internal config.
#
@config
.
merge
(
to_hash
.
compact
)
end
private
def
to_hash
{
before_script:
before_script
,
stage:
stage
}
end
def
compose!
super
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
3c5b1da2
...
...
@@ -970,7 +970,7 @@ EOT
config
=
YAML
.
dump
({
rspec:
{
script:
"test"
,
before_script:
[
10
,
"test"
]
}
})
expect
do
GitlabCiYamlProcessor
.
new
(
config
,
path
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
rspec job: before_script
should be an array of strings"
)
end
.
to
raise_error
(
GitlabCiYamlProcessor
::
ValidationError
,
"
jobs:rspec:before_script config
should be an array of strings"
)
end
it
"returns errors if after_script parameter is invalid"
do
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
3c5b1da2
...
...
@@ -4,23 +4,15 @@ describe Gitlab::Ci::Config::Node::Job do
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
global
)
}
let
(
:global
)
{
spy
(
'Global'
)
}
describe
'validations'
do
before
do
entry
.
process!
entry
.
validate!
end
describe
'validations'
do
context
'when entry config value is correct'
do
let
(
:config
)
{
{
script:
'rspec'
}
}
describe
'#value'
do
it
'returns key value'
do
expect
(
entry
.
value
)
.
to
eq
(
script:
'rspec'
,
stage:
'test'
)
end
end
describe
'#valid?'
do
it
'is valid'
do
expect
(
entry
).
to
be_valid
...
...
@@ -33,7 +25,7 @@ describe Gitlab::Ci::Config::Node::Job do
let
(
:config
)
{
[
'incorrect'
]
}
describe
'#errors'
do
it
'
saves errors
'
do
it
'
reports error about a config type
'
do
expect
(
entry
.
errors
)
.
to
include
'job config should be a hash'
end
...
...
@@ -52,6 +44,32 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
describe
'#value'
do
context
'when entry is correct'
do
let
(
:config
)
do
{
before_script:
%w[ls pwd]
,
script:
'rspec'
}
end
it
'returns correct value'
do
expect
(
entry
.
value
)
.
to
eq
(
before_script:
%w[ls pwd]
,
script:
'rspec'
,
stage:
'test'
)
end
end
context
'when entry is incorrect'
do
let
(
:config
)
{
{}
}
it
'raises error'
do
expect
{
entry
.
value
}.
to
raise_error
(
Gitlab
::
Ci
::
Config
::
Node
::
Entry
::
InvalidError
)
end
end
end
describe
'#relevant?'
do
it
'is a relevant entry'
do
expect
(
entry
).
to
be_relevant
...
...
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