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
Jérome Perrin
gitlab-ce
Commits
036e297c
Commit
036e297c
authored
Jul 13, 2016
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Expose CI job commands and use in legacy processor
parent
6920390a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
33 additions
and
21 deletions
+33
-21
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+6
-7
lib/gitlab/ci/config/node/job.rb
lib/gitlab/ci/config/node/job.rb
+8
-7
spec/lib/gitlab/ci/config/node/global_spec.rb
spec/lib/gitlab/ci/config/node/global_spec.rb
+9
-3
spec/lib/gitlab/ci/config/node/job_spec.rb
spec/lib/gitlab/ci/config/node/job_spec.rb
+2
-1
spec/lib/gitlab/ci/config/node/jobs_spec.rb
spec/lib/gitlab/ci/config/node/jobs_spec.rb
+8
-3
No files found.
lib/ci/gitlab_ci_yaml_processor.rb
View file @
036e297c
...
@@ -80,12 +80,7 @@ module Ci
...
@@ -80,12 +80,7 @@ module Ci
{
{
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage_idx:
@stages
.
index
(
job
[
:stage
]),
stage:
job
[
:stage
],
stage:
job
[
:stage
],
##
commands:
job
[
:commands
],
# Refactoring note:
# - before script behaves differently than after script
# - after script returns an array of commands
# - before script should be a concatenated command
commands:
[
job
[
:before_script
]
||
@before_script
,
job
[
:script
]].
flatten
.
compact
.
join
(
"
\n
"
),
tag_list:
job
[
:tags
]
||
[],
tag_list:
job
[
:tags
]
||
[],
name:
name
,
name:
name
,
only:
job
[
:only
],
only:
job
[
:only
],
...
@@ -124,8 +119,12 @@ module Ci
...
@@ -124,8 +119,12 @@ module Ci
end
end
def
validate_job_keys!
(
name
,
job
)
def
validate_job_keys!
(
name
,
job
)
##
# TODO, remove refactoring keys
#
refactoring_keys
=
[
:commands
]
job
.
keys
.
each
do
|
key
|
job
.
keys
.
each
do
|
key
|
unless
ALLOWED_JOB_KEYS
.
include?
key
unless
(
ALLOWED_JOB_KEYS
+
refactoring_keys
)
.
include?
key
raise
ValidationError
,
"
#{
name
}
job: unknown parameter
#{
key
}
"
raise
ValidationError
,
"
#{
name
}
job: unknown parameter
#{
key
}
"
end
end
end
end
...
...
lib/gitlab/ci/config/node/job.rb
View file @
036e297c
...
@@ -40,23 +40,24 @@ module Gitlab
...
@@ -40,23 +40,24 @@ module Gitlab
def
before_script
def
before_script
if
before_script_defined?
if
before_script_defined?
before_script_value
.
to_a
before_script_value
else
else
@global
.
before_script
.
to_a
@global
.
before_script
end
end
end
end
def
commands
def
commands
(
before_script
+
script
)
.
join
(
"
\n
"
)
[
before_script
,
script
].
compact
.
join
(
"
\n
"
)
end
end
private
private
def
to_hash
def
to_hash
{
before_script:
before_script_value
,
{
before_script:
before_script
,
script:
script_value
,
script:
script
,
stage:
stage_value
,
commands:
commands
,
after_script:
after_script_value
}
stage:
stage
,
after_script:
after_script
}
end
end
def
compose!
def
compose!
...
...
spec/lib/gitlab/ci/config/node/global_spec.rb
View file @
036e297c
...
@@ -23,7 +23,7 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -23,7 +23,7 @@ describe Gitlab::Ci::Config::Node::Global do
after_script:
[
'make clean'
],
after_script:
[
'make clean'
],
stages:
[
'build'
,
'pages'
],
stages:
[
'build'
,
'pages'
],
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
cache:
{
key:
'k'
,
untracked:
true
,
paths:
[
'public/'
]
},
rspec:
{
script:
'rspec'
},
rspec:
{
script:
%w[rspec ls]
},
spinach:
{
script:
'spinach'
}
}
spinach:
{
script:
'spinach'
}
}
end
end
...
@@ -129,8 +129,14 @@ describe Gitlab::Ci::Config::Node::Global do
...
@@ -129,8 +129,14 @@ 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:
%w[rspec]
,
stage:
'test'
},
.
to
eq
(
rspec:
{
before_script:
%w[ls pwd]
,
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
script:
%w[rspec ls]
,
commands:
"ls
\n
pwd
\n
rspec
\n
ls"
,
stage:
'test'
},
spinach:
{
before_script:
%w[ls pwd]
,
script:
%w[spinach]
,
commands:
"ls
\n
pwd
\n
spinach"
,
stage:
'test'
})
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/job_spec.rb
View file @
036e297c
...
@@ -56,6 +56,7 @@ describe Gitlab::Ci::Config::Node::Job do
...
@@ -56,6 +56,7 @@ describe Gitlab::Ci::Config::Node::Job do
expect
(
entry
.
value
)
expect
(
entry
.
value
)
.
to
eq
(
before_script:
%w[ls pwd]
,
.
to
eq
(
before_script:
%w[ls pwd]
,
script:
%w[rspec]
,
script:
%w[rspec]
,
commands:
"ls
\n
pwd
\n
rspec"
,
stage:
'test'
,
stage:
'test'
,
after_script:
%w[cleanup]
)
after_script:
%w[cleanup]
)
end
end
...
@@ -114,7 +115,7 @@ describe Gitlab::Ci::Config::Node::Job do
...
@@ -114,7 +115,7 @@ describe Gitlab::Ci::Config::Node::Job do
end
end
it
'returns correct script'
do
it
'returns correct script'
do
expect
(
entry
.
before_script
).
to
eq
[]
expect
(
entry
.
before_script
).
to
be_nil
end
end
end
end
end
end
...
...
spec/lib/gitlab/ci/config/node/jobs_spec.rb
View file @
036e297c
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Config
::
Node
::
Jobs
do
describe
Gitlab
::
Ci
::
Config
::
Node
::
Jobs
do
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
spy
)
}
let
(
:entry
)
{
described_class
.
new
(
config
,
global:
global
)
}
let
(
:global
)
{
double
(
'global'
,
before_script:
nil
,
stages:
%w[test]
)
}
describe
'validations'
do
describe
'validations'
do
before
do
before
do
...
@@ -62,8 +63,12 @@ describe Gitlab::Ci::Config::Node::Jobs do
...
@@ -62,8 +63,12 @@ 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:
%w[rspec]
,
stage:
'test'
},
.
to
eq
(
rspec:
{
script:
%w[rspec]
,
spinach:
{
script:
%w[spinach]
,
stage:
'test'
})
commands:
'rspec'
,
stage:
'test'
},
spinach:
{
script:
%w[spinach]
,
commands:
'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