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
c70e9f2e
Commit
c70e9f2e
authored
Jun 05, 2017
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send new configuration options with job's payload
parent
8c6e2bad
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
75 additions
and
16 deletions
+75
-16
lib/api/entities.rb
lib/api/entities.rb
+6
-2
lib/gitlab/ci/build/image.rb
lib/gitlab/ci/build/image.rb
+9
-2
spec/factories/ci/builds.rb
spec/factories/ci/builds.rb
+2
-2
spec/lib/gitlab/ci/build/image_spec.rb
spec/lib/gitlab/ci/build/image_spec.rb
+53
-8
spec/requests/api/runner_spec.rb
spec/requests/api/runner_spec.rb
+5
-2
No files found.
lib/api/entities.rb
View file @
c70e9f2e
...
...
@@ -804,7 +804,11 @@ module API
end
class
Image
<
Grape
::
Entity
expose
:name
expose
:name
,
:entrypoint
end
class
ServiceImage
<
Image
expose
:alias
,
:command
end
class
Artifacts
<
Grape
::
Entity
...
...
@@ -848,7 +852,7 @@ module API
expose
:variables
expose
:steps
,
using:
Step
expose
:image
,
using:
Image
expose
:services
,
using:
Image
expose
:services
,
using:
Service
Image
expose
:artifacts
,
using:
Artifacts
expose
:cache
,
using:
Cache
expose
:credentials
,
using:
Credentials
...
...
lib/gitlab/ci/build/image.rb
View file @
c70e9f2e
...
...
@@ -2,7 +2,7 @@ module Gitlab
module
Ci
module
Build
class
Image
attr_reader
:name
attr_reader
:
alias
,
:command
,
:entrypoint
,
:
name
class
<<
self
def
from_image
(
job
)
...
...
@@ -21,7 +21,14 @@ module Gitlab
end
def
initialize
(
image
)
@name
=
image
if
image
.
is_a?
(
String
)
@name
=
image
elsif
image
.
is_a?
(
Hash
)
@alias
=
image
[
:alias
]
@command
=
image
[
:command
]
@entrypoint
=
image
[
:entrypoint
]
@name
=
image
[
:name
]
end
end
def
valid?
...
...
spec/factories/ci/builds.rb
View file @
c70e9f2e
...
...
@@ -194,8 +194,8 @@ FactoryGirl.define do
trait
:extended_options
do
options
do
{
image:
'ruby:2.1'
,
services:
[
'postgres'
],
image:
{
name:
'ruby:2.1'
,
entrypoint:
'/bin/sh'
}
,
services:
[
'postgres'
,
{
name:
'docker:dind'
,
entrypoint:
'/bin/sh'
,
command:
'sleep 30'
,
alias:
'docker'
}
],
after_script:
%w(ls date)
,
artifacts:
{
name:
'artifacts_file'
,
...
...
spec/lib/gitlab/ci/build/image_spec.rb
View file @
c70e9f2e
...
...
@@ -10,12 +10,28 @@ describe Gitlab::Ci::Build::Image do
let
(
:image_name
)
{
'ruby:2.1'
}
let
(
:job
)
{
create
(
:ci_build
,
options:
{
image:
image_name
}
)
}
it
'fabricates an object of the proper class'
do
is_expected
.
to
be_kind_of
(
described_class
)
context
'when image is defined as string'
do
it
'fabricates an object of the proper class'
do
is_expected
.
to
be_kind_of
(
described_class
)
end
it
'populates fabricated object with the proper name attribute'
do
expect
(
subject
.
name
).
to
eq
(
image_name
)
end
end
it
'populates fabricated object with the proper name attribute'
do
expect
(
subject
.
name
).
to
eq
(
image_name
)
context
'when image is defined as hash'
do
let
(
:entrypoint
)
{
'/bin/sh'
}
let
(
:job
)
{
create
(
:ci_build
,
options:
{
image:
{
name:
image_name
,
entrypoint:
entrypoint
}
}
)
}
it
'fabricates an object of the proper class'
do
is_expected
.
to
be_kind_of
(
described_class
)
end
it
'populates fabricated object with the proper attributes'
do
expect
(
subject
.
name
).
to
eq
(
image_name
)
expect
(
subject
.
entrypoint
).
to
eq
(
entrypoint
)
end
end
context
'when image name is empty'
do
...
...
@@ -41,10 +57,39 @@ describe Gitlab::Ci::Build::Image do
let
(
:service_image_name
)
{
'postgres'
}
let
(
:job
)
{
create
(
:ci_build
,
options:
{
services:
[
service_image_name
]
})
}
it
'fabricates an non-empty array of objects'
do
is_expected
.
to
be_kind_of
(
Array
)
is_expected
.
not_to
be_empty
expect
(
subject
.
first
.
name
).
to
eq
(
service_image_name
)
context
'when service is defined as string'
do
it
'fabricates an non-empty array of objects'
do
is_expected
.
to
be_kind_of
(
Array
)
is_expected
.
not_to
be_empty
end
it
'populates fabricated objects with the proper name attributes'
do
expect
(
subject
.
first
).
to
be_kind_of
(
described_class
)
expect
(
subject
.
first
.
name
).
to
eq
(
service_image_name
)
end
end
context
'when service is defined as hash'
do
let
(
:service_entrypoint
)
{
'/bin/sh'
}
let
(
:service_alias
)
{
'db'
}
let
(
:service_command
)
{
'sleep 30'
}
let
(
:job
)
do
create
(
:ci_build
,
options:
{
services:
[{
name:
service_image_name
,
entrypoint:
service_entrypoint
,
alias:
service_alias
,
command:
service_command
}]
})
end
it
'fabricates an non-empty array of objects'
do
is_expected
.
to
be_kind_of
(
Array
)
is_expected
.
not_to
be_empty
expect
(
subject
.
first
).
to
be_kind_of
(
described_class
)
end
it
'populates fabricated objects with the proper attributes'
do
expect
(
subject
.
first
.
name
).
to
eq
(
service_image_name
)
expect
(
subject
.
first
.
entrypoint
).
to
eq
(
service_entrypoint
)
expect
(
subject
.
first
.
alias
).
to
eq
(
service_alias
)
expect
(
subject
.
first
.
command
).
to
eq
(
service_command
)
end
end
context
'when service image name is empty'
do
...
...
spec/requests/api/runner_spec.rb
View file @
c70e9f2e
...
...
@@ -356,8 +356,11 @@ describe API::Runner do
expect
(
json_response
[
'token'
]).
to
eq
(
job
.
token
)
expect
(
json_response
[
'job_info'
]).
to
eq
(
expected_job_info
)
expect
(
json_response
[
'git_info'
]).
to
eq
(
expected_git_info
)
expect
(
json_response
[
'image'
]).
to
eq
({
'name'
=>
'ruby:2.1'
})
expect
(
json_response
[
'services'
]).
to
eq
([{
'name'
=>
'postgres'
}])
expect
(
json_response
[
'image'
]).
to
eq
({
'name'
=>
'ruby:2.1'
,
'entrypoint'
=>
'/bin/sh'
})
expect
(
json_response
[
'services'
]).
to
eq
([{
'name'
=>
'postgres'
,
'entrypoint'
=>
nil
,
'alias'
=>
nil
,
'command'
=>
nil
},
{
'name'
=>
'docker:dind'
,
'entrypoint'
=>
'/bin/sh'
,
'alias'
=>
'docker'
,
'command'
=>
'sleep 30'
}])
expect
(
json_response
[
'steps'
]).
to
eq
(
expected_steps
)
expect
(
json_response
[
'artifacts'
]).
to
eq
(
expected_artifacts
)
expect
(
json_response
[
'cache'
]).
to
eq
(
expected_cache
)
...
...
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