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
e3fb0740
Commit
e3fb0740
authored
Nov 20, 2016
by
Tomasz Maczukin
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Send credentials array with build data
parent
596bbf67
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
58 additions
and
19 deletions
+58
-19
app/models/ci/build.rb
app/models/ci/build.rb
+11
-0
changelogs/unreleased/feature-send-registry-address-with-build-payload.yml
...ased/feature-send-registry-address-with-build-payload.yml
+1
-1
lib/ci/api/entities.rb
lib/ci/api/entities.rb
+5
-3
lib/gitlab/ci/build/credentials.rb
lib/gitlab/ci/build/credentials.rb
+16
-0
spec/requests/ci/api/builds_spec.rb
spec/requests/ci/api/builds_spec.rb
+25
-15
No files found.
app/models/ci/build.rb
View file @
e3fb0740
...
@@ -448,8 +448,19 @@ module Ci
...
@@ -448,8 +448,19 @@ module Ci
]
]
end
end
def
credentials
[
build_container_registry_credentials
].
compact
end
private
private
def
build_container_registry_credentials
return
unless
Gitlab
.
config
.
registry
.
enabled
Gitlab
::
Ci
::
Build
::
Credentials
.
new
(
'docker-registry'
,
Gitlab
.
config
.
registry
.
host_port
,
'gitlab-ci-token'
,
token
)
end
def
update_artifacts_size
def
update_artifacts_size
self
.
artifacts_size
=
if
artifacts_file
.
exists?
self
.
artifacts_size
=
if
artifacts_file
.
exists?
artifacts_file
.
size
artifacts_file
.
size
...
...
changelogs/unreleased/feature-send-registry-address-with-build-payload.yml
View file @
e3fb0740
---
---
title
:
Send
registry_url
with build data to GitLab Runner
title
:
Send
credentials (currently for registry only)
with build data to GitLab Runner
merge_request
:
7474
merge_request
:
7474
author
:
author
:
lib/ci/api/entities.rb
View file @
e3fb0740
...
@@ -32,6 +32,10 @@ module Ci
...
@@ -32,6 +32,10 @@ module Ci
expose
:artifacts_file
,
using:
ArtifactFile
,
if:
->
(
build
,
_
)
{
build
.
artifacts?
}
expose
:artifacts_file
,
using:
ArtifactFile
,
if:
->
(
build
,
_
)
{
build
.
artifacts?
}
end
end
class
BuildCredentials
<
Grape
::
Entity
expose
:type
,
:url
,
:username
,
:password
end
class
BuildDetails
<
Build
class
BuildDetails
<
Build
expose
:commands
expose
:commands
expose
:repo_url
expose
:repo_url
...
@@ -51,9 +55,7 @@ module Ci
...
@@ -51,9 +55,7 @@ module Ci
expose
:variables
expose
:variables
expose
:depends_on_builds
,
using:
Build
expose
:depends_on_builds
,
using:
Build
expose
:registry_url
,
if:
->
(
_
,
_
)
{
Gitlab
.
config
.
registry
.
enabled
}
do
|
_
|
expose
:credentials
,
using:
BuildCredentials
Gitlab
.
config
.
registry
.
host_port
end
end
end
class
Runner
<
Grape
::
Entity
class
Runner
<
Grape
::
Entity
...
...
lib/gitlab/ci/build/credentials.rb
0 → 100644
View file @
e3fb0740
module
Gitlab
module
Ci
module
Build
class
Credentials
attr_accessor
:type
,
:url
,
:username
,
:password
def
initialize
(
type
,
url
,
username
,
password
)
@type
=
type
@url
=
url
@username
=
username
@password
=
password
end
end
end
end
end
spec/requests/ci/api/builds_spec.rb
View file @
e3fb0740
...
@@ -58,28 +58,38 @@ describe Ci::API::API do
...
@@ -58,28 +58,38 @@ describe Ci::API::API do
expect
{
register_builds
}.
to
change
{
runner
.
reload
.
contacted_at
}
expect
{
register_builds
}.
to
change
{
runner
.
reload
.
contacted_at
}
end
end
context
'when registry is enabled'
do
context
'registry credentials'
do
before
do
let
(
:registry_credentials
)
do
stub_container_registry_config
(
enabled:
true
,
host_port:
'registry.example.com:5005'
)
{
'type'
=>
'docker-registry'
,
'url'
=>
'registry.example.com:5005'
,
'username'
=>
'gitlab-ci-token'
,
'password'
=>
build
.
token
}
end
end
it
'sends registry_url key'
do
context
'when registry is enabled'
do
register_builds
info:
{
platform: :darwin
}
before
do
stub_container_registry_config
(
enabled:
true
,
host_port:
'registry.example.com:5005'
)
end
expect
(
json_response
).
to
have_key
(
'registry_url'
)
it
'sends registry credentials key'
do
expect
(
json_response
[
'registry_url'
]).
to
eq
(
"registry.example.com:5005"
)
register_builds
info:
{
platform: :darwin
}
end
end
context
'when registry is disabled'
do
expect
(
json_response
).
to
have_key
(
'credentials'
)
before
do
expect
(
json_response
[
'credentials'
]).
to
include
(
registry_credentials
)
stub_container_registry_config
(
enabled:
false
,
host_port:
'registry.example.com:5005'
)
end
end
end
it
'does not send registry_url key'
do
context
'when registry is disabled'
do
register_builds
info:
{
platform: :darwin
}
before
do
stub_container_registry_config
(
enabled:
false
,
host_port:
'registry.example.com:5005'
)
end
expect
(
json_response
).
not_to
have_key
(
'registry_url'
)
it
'does not send registry credentials'
do
register_builds
info:
{
platform: :darwin
}
expect
(
json_response
).
to
have_key
(
'credentials'
)
expect
(
json_response
[
'credentials'
]).
not_to
include
(
registry_credentials
)
end
end
end
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