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
1
Merge Requests
1
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
nexedi
gitlab-ce
Commits
a04512cd
Commit
a04512cd
authored
Apr 19, 2018
by
Mayra Cabrera
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Ensure deploy tokens variables are not available in the context of only/except
parent
82add03f
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
16 additions
and
9 deletions
+16
-9
app/models/ci/build.rb
app/models/ci/build.rb
+5
-3
doc/ci/environments.md
doc/ci/environments.md
+2
-0
doc/ci/variables/README.md
doc/ci/variables/README.md
+2
-0
spec/models/ci/build_spec.rb
spec/models/ci/build_spec.rb
+6
-5
spec/models/project_spec.rb
spec/models/project_spec.rb
+1
-1
No files found.
app/models/ci/build.rb
View file @
a04512cd
...
...
@@ -31,6 +31,7 @@ module Ci
has_one
:metadata
,
class_name:
'Ci::BuildMetadata'
delegate
:timeout
,
to: :metadata
,
prefix:
true
,
allow_nil:
true
delegate
:gitlab_deploy_token
,
to: :project
##
# The "environment" field for builds is a String, and is the unexpanded name!
...
...
@@ -608,6 +609,8 @@ module Ci
.
append
(
key:
'CI_REGISTRY_USER'
,
value:
CI_REGISTRY_USER
)
.
append
(
key:
'CI_REGISTRY_PASSWORD'
,
value:
token
,
public:
false
)
.
append
(
key:
'CI_REPOSITORY_URL'
,
value:
repo_url
,
public:
false
)
variables
.
concat
(
deploy_token_variables
)
if
gitlab_deploy_token
end
end
...
...
@@ -628,7 +631,6 @@ module Ci
variables
.
append
(
key:
"CI_PIPELINE_TRIGGERED"
,
value:
'true'
)
if
trigger_request
variables
.
append
(
key:
"CI_JOB_MANUAL"
,
value:
'true'
)
if
action?
variables
.
concat
(
legacy_variables
)
variables
.
concat
(
deploy_token_variables
)
if
project
.
gitlab_deploy_token
end
end
...
...
@@ -661,8 +663,8 @@ module Ci
def
deploy_token_variables
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
tap
do
|
variables
|
variables
.
append
(
key:
'CI_DEPLOY_USER'
,
value:
DeployToken
::
GITLAB_DEPLOY_TOKEN_NAME
)
variables
.
append
(
key:
'CI_DEPLOY_PASSWORD'
,
value:
project
.
gitlab_deploy_token
.
token
)
variables
.
append
(
key:
'CI_DEPLOY_USER'
,
value:
gitlab_deploy_token
.
name
)
variables
.
append
(
key:
'CI_DEPLOY_PASSWORD'
,
value:
gitlab_deploy_token
.
token
)
end
end
...
...
doc/ci/environments.md
View file @
a04512cd
...
...
@@ -260,6 +260,8 @@ are unsupported in environment name context:
-
`CI_REGISTRY_PASSWORD`
-
`CI_REPOSITORY_URL`
-
`CI_ENVIRONMENT_URL`
-
`CI_DEPLOY_USER`
-
`CI_DEPLOY_PASSWORD`
GitLab Runner exposes various
[
environment variables
][
variables
]
when a job runs,
and as such, you can use them as environment names. Let's add another job in
...
...
doc/ci/variables/README.md
View file @
a04512cd
...
...
@@ -569,6 +569,8 @@ You can find a full list of unsupported variables below:
-
`CI_REGISTRY_PASSWORD`
-
`CI_REPOSITORY_URL`
-
`CI_ENVIRONMENT_URL`
-
`CI_DEPLOY_USER`
-
`CI_DEPLOY_PASSWORD`
These variables are also not supported in a contex of a
[
dynamic environment name
][
dynamic-environments
]
.
...
...
spec/models/ci/build_spec.rb
View file @
a04512cd
...
...
@@ -2061,7 +2061,7 @@ describe Ci::Build do
let
(
:deploy_token_variables
)
do
[
{
key:
'CI_DEPLOY_USER'
,
value:
DeployToken
::
GITLAB_DEPLOY_TOKEN_NAME
,
public:
true
},
{
key:
'CI_DEPLOY_USER'
,
value:
deploy_token
.
name
,
public:
true
},
{
key:
'CI_DEPLOY_PASSWORD'
,
value:
deploy_token
.
token
,
public:
true
}
]
end
...
...
@@ -2078,9 +2078,8 @@ describe Ci::Build do
context
'when gitlab-deploy-token does not exist'
do
it
'should not include deploy token variables'
do
%w(CI_DEPLOY_USER CI_DEPLOY_PASSWORD)
.
each
do
|
deploy_token_key
|
expect
(
subject
.
find
{
|
v
|
v
[
:key
]
==
deploy_token_key
}).
to
be_nil
end
expect
(
subject
.
find
{
|
v
|
v
[
:key
]
==
'CI_DEPLOY_USER'
}).
to
be_nil
expect
(
subject
.
find
{
|
v
|
v
[
:key
]
==
'CI_DEPLOY_PASSWORD'
}).
to
be_nil
end
end
end
...
...
@@ -2132,7 +2131,9 @@ describe Ci::Build do
CI_REGISTRY_USER
CI_REGISTRY_PASSWORD
CI_REPOSITORY_URL
CI_ENVIRONMENT_URL]
CI_ENVIRONMENT_URL
CI_DEPLOY_USER
CI_DEPLOY_PASSWORD]
build
.
scoped_variables
.
map
{
|
env
|
env
[
:key
]
}.
tap
do
|
names
|
expect
(
names
).
not_to
include
(
*
keys
)
...
...
spec/models/project_spec.rb
View file @
a04512cd
...
...
@@ -4002,7 +4002,7 @@ describe Project do
it
{
is_expected
.
to
be_nil
}
end
context
'when there is a
gitlab
deploy token associated with a different name'
do
context
'when there is a deploy token associated with a different name'
do
let!
(
:deploy_token
)
{
create
(
:deploy_token
,
projects:
[
project
])
}
it
{
is_expected
.
to
be_nil
}
...
...
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