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
6d272f8e
Commit
6d272f8e
authored
Jul 06, 2017
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Pass before_script and script as-is preserving arrays
parent
d6836a3b
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
80 additions
and
25 deletions
+80
-25
changelogs/unreleased/pass-before-script-as-is.yml
changelogs/unreleased/pass-before-script-as-is.yml
+4
-0
lib/ci/gitlab_ci_yaml_processor.rb
lib/ci/gitlab_ci_yaml_processor.rb
+2
-0
lib/gitlab/ci/build/step.rb
lib/gitlab/ci/build/step.rb
+2
-1
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
+33
-14
spec/lib/gitlab/ci/build/step_spec.rb
spec/lib/gitlab/ci/build/step_spec.rb
+39
-10
No files found.
changelogs/unreleased/pass-before-script-as-is.yml
0 → 100644
View file @
6d272f8e
---
title
:
Pass before_script and script as-is preserving arrays
merge_request
:
author
:
lib/ci/gitlab_ci_yaml_processor.rb
View file @
6d272f8e
...
@@ -80,6 +80,8 @@ module Ci
...
@@ -80,6 +80,8 @@ module Ci
artifacts:
job
[
:artifacts
],
artifacts:
job
[
:artifacts
],
cache:
job
[
:cache
],
cache:
job
[
:cache
],
dependencies:
job
[
:dependencies
],
dependencies:
job
[
:dependencies
],
before_script:
job
[
:before_script
],
script:
job
[
:script
],
after_script:
job
[
:after_script
],
after_script:
job
[
:after_script
],
environment:
job
[
:environment
]
environment:
job
[
:environment
]
}.
compact
}
}.
compact
}
...
...
lib/gitlab/ci/build/step.rb
View file @
6d272f8e
...
@@ -12,7 +12,8 @@ module Gitlab
...
@@ -12,7 +12,8 @@ module Gitlab
class
<<
self
class
<<
self
def
from_commands
(
job
)
def
from_commands
(
job
)
self
.
new
(
:script
).
tap
do
|
step
|
self
.
new
(
:script
).
tap
do
|
step
|
step
.
script
=
job
.
commands
.
split
(
"
\n
"
)
step
.
script
=
job
.
options
[
:before_script
].
to_a
+
job
.
options
[
:script
].
to_a
step
.
script
=
job
.
commands
.
split
(
"
\n
"
)
if
step
.
script
.
empty?
step
.
timeout
=
job
.
timeout
step
.
timeout
=
job
.
timeout
step
.
when
=
WHEN_ON_SUCCESS
step
.
when
=
WHEN_ON_SUCCESS
end
end
...
...
spec/lib/ci/gitlab_ci_yaml_processor_spec.rb
View file @
6d272f8e
...
@@ -163,7 +163,10 @@ module Ci
...
@@ -163,7 +163,10 @@ module Ci
commands:
"pwd
\n
rspec"
,
commands:
"pwd
\n
rspec"
,
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{},
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
]
},
allow_failure:
false
,
allow_failure:
false
,
when:
"on_success"
,
when:
"on_success"
,
environment:
nil
,
environment:
nil
,
...
@@ -616,6 +619,8 @@ module Ci
...
@@ -616,6 +619,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
],
image:
{
name:
"ruby:2.1"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
]
},
image:
{
name:
"ruby:2.1"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
]
},
services:
[{
name:
"mysql"
},
services:
[{
name:
"mysql"
},
{
name:
"docker:dind"
,
alias:
"docker"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
],
{
name:
"docker:dind"
,
alias:
"docker"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
],
...
@@ -649,6 +654,8 @@ module Ci
...
@@ -649,6 +654,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
],
image:
{
name:
"ruby:2.5"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
]
},
image:
{
name:
"ruby:2.5"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
]
},
services:
[{
name:
"postgresql"
,
alias:
"db-pg"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
],
services:
[{
name:
"postgresql"
,
alias:
"db-pg"
,
entrypoint:
[
"/usr/local/bin/init"
,
"run"
],
command:
[
"/usr/local/bin/init"
,
"run"
]
},
command:
[
"/usr/local/bin/init"
,
"run"
]
},
...
@@ -680,6 +687,8 @@ module Ci
...
@@ -680,6 +687,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
],
image:
{
name:
"ruby:2.1"
},
image:
{
name:
"ruby:2.1"
},
services:
[{
name:
"mysql"
},
{
name:
"docker:dind"
}]
services:
[{
name:
"mysql"
},
{
name:
"docker:dind"
}]
},
},
...
@@ -707,6 +716,8 @@ module Ci
...
@@ -707,6 +716,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
],
image:
{
name:
"ruby:2.5"
},
image:
{
name:
"ruby:2.5"
},
services:
[{
name:
"postgresql"
},
{
name:
"docker:dind"
}]
services:
[{
name:
"postgresql"
},
{
name:
"docker:dind"
}]
},
},
...
@@ -951,6 +962,8 @@ module Ci
...
@@ -951,6 +962,8 @@ module Ci
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{
options:
{
before_script:
[
"pwd"
],
script:
[
"rspec"
],
image:
{
name:
"ruby:2.1"
},
image:
{
name:
"ruby:2.1"
},
services:
[{
name:
"mysql"
}],
services:
[{
name:
"mysql"
}],
artifacts:
{
artifacts:
{
...
@@ -1162,7 +1175,9 @@ module Ci
...
@@ -1162,7 +1175,9 @@ module Ci
commands:
"test"
,
commands:
"test"
,
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{},
options:
{
script:
[
"test"
]
},
when:
"on_success"
,
when:
"on_success"
,
allow_failure:
false
,
allow_failure:
false
,
environment:
nil
,
environment:
nil
,
...
@@ -1208,7 +1223,9 @@ module Ci
...
@@ -1208,7 +1223,9 @@ module Ci
commands:
"execute-script-for-job"
,
commands:
"execute-script-for-job"
,
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{},
options:
{
script:
[
"execute-script-for-job"
]
},
when:
"on_success"
,
when:
"on_success"
,
allow_failure:
false
,
allow_failure:
false
,
environment:
nil
,
environment:
nil
,
...
@@ -1221,7 +1238,9 @@ module Ci
...
@@ -1221,7 +1238,9 @@ module Ci
commands:
"execute-script-for-job"
,
commands:
"execute-script-for-job"
,
coverage_regex:
nil
,
coverage_regex:
nil
,
tag_list:
[],
tag_list:
[],
options:
{},
options:
{
script:
[
"execute-script-for-job"
]
},
when:
"on_success"
,
when:
"on_success"
,
allow_failure:
false
,
allow_failure:
false
,
environment:
nil
,
environment:
nil
,
...
...
spec/lib/gitlab/ci/build/step_spec.rb
View file @
6d272f8e
require
'spec_helper'
require
'spec_helper'
describe
Gitlab
::
Ci
::
Build
::
Step
do
describe
Gitlab
::
Ci
::
Build
::
Step
do
let
(
:job
)
{
create
(
:ci_build
,
:no_options
,
commands:
"ls -la
\n
date"
)
}
describe
'#from_commands'
do
describe
'#from_commands'
do
shared_examples
'has correct script'
do
subject
{
described_class
.
from_commands
(
job
)
}
subject
{
described_class
.
from_commands
(
job
)
}
it
'fabricates an object'
do
it
'fabricates an object'
do
expect
(
subject
.
name
).
to
eq
(
:script
)
expect
(
subject
.
name
).
to
eq
(
:script
)
expect
(
subject
.
script
).
to
eq
([
'ls -la'
,
'date'
]
)
expect
(
subject
.
script
).
to
eq
(
script
)
expect
(
subject
.
timeout
).
to
eq
(
job
.
timeout
)
expect
(
subject
.
timeout
).
to
eq
(
job
.
timeout
)
expect
(
subject
.
when
).
to
eq
(
'on_success'
)
expect
(
subject
.
when
).
to
eq
(
'on_success'
)
expect
(
subject
.
allow_failure
).
to
be_falsey
expect
(
subject
.
allow_failure
).
to
be_falsey
end
end
end
end
context
'when commands are specified'
do
it_behaves_like
'has correct script'
do
let
(
:job
)
{
create
(
:ci_build
,
:no_options
,
commands:
"ls -la
\n
date"
)
}
let
(
:script
)
{
[
'ls -la'
,
'date'
]
}
end
end
context
'when script option is specified'
do
it_behaves_like
'has correct script'
do
let
(
:job
)
{
create
(
:ci_build
,
:no_options
,
options:
{
script:
[
"ls -la
\n
echo aaa"
,
"date"
]
})
}
let
(
:script
)
{
[
"ls -la
\n
echo aaa"
,
'date'
]
}
end
end
context
'when before and script option is specified'
do
it_behaves_like
'has correct script'
do
let
(
:job
)
do
create
(
:ci_build
,
options:
{
before_script:
[
"ls -la
\n
echo aaa"
],
script:
[
"date"
]
})
end
let
(
:script
)
{
[
"ls -la
\n
echo aaa"
,
'date'
]
}
end
end
end
describe
'#from_after_script'
do
describe
'#from_after_script'
do
let
(
:job
)
{
create
(
:ci_build
)
}
subject
{
described_class
.
from_after_script
(
job
)
}
subject
{
described_class
.
from_after_script
(
job
)
}
context
'when after_script is empty'
do
context
'when after_script is empty'
do
...
...
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