BigW Consortium Gitlab
Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
gitlab-ce
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Forest Godfrey
gitlab-ce
Commits
d9a3f020
Commit
d9a3f020
authored
May 18, 2018
by
Grzegorz Bizon
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Separate persisted and runtime pipeline variables
parent
9f7deb85
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
30 additions
and
2 deletions
+30
-2
build.rb
app/models/ci/build.rb
+1
-0
pipeline.rb
app/models/ci/pipeline.rb
+1
-1
build_spec.rb
spec/models/ci/build_spec.rb
+8
-0
create_pipeline_service_spec.rb
spec/services/ci/create_pipeline_service_spec.rb
+20
-1
No files found.
app/models/ci/build.rb
View file @
d9a3f020
...
...
@@ -599,6 +599,7 @@ module Ci
break
variables
unless
persisted?
variables
.
concat
(
pipeline
.
persisted_variables
)
.
append
(
key:
'CI_JOB_ID'
,
value:
id
.
to_s
)
.
append
(
key:
'CI_JOB_TOKEN'
,
value:
token
,
public:
false
)
.
append
(
key:
'CI_BUILD_ID'
,
value:
id
.
to_s
)
...
...
app/models/ci/pipeline.rb
View file @
d9a3f020
...
...
@@ -530,7 +530,7 @@ module Ci
end
def
predefined_variables
persisted_variables
Gitlab
::
Ci
::
Variables
::
Collection
.
new
.
append
(
key:
'CI_CONFIG_PATH'
,
value:
ci_yaml_file_path
)
.
append
(
key:
'CI_PIPELINE_SOURCE'
,
value:
source
.
to_s
)
.
append
(
key:
'CI_COMMIT_MESSAGE'
,
value:
git_commit_message
)
...
...
spec/models/ci/build_spec.rb
View file @
d9a3f020
...
...
@@ -629,6 +629,14 @@ describe Ci::Build do
it
{
is_expected
.
to
eq
(
'review/host'
)
}
end
context
'when using persisted variables'
do
let
(
:build
)
do
create
(
:ci_build
,
environment:
'review/x$CI_BUILD_ID'
)
end
it
{
is_expected
.
to
eq
(
'review/x'
)
}
end
end
describe
'#starts_environment?'
do
...
...
spec/services/ci/create_pipeline_service_spec.rb
View file @
d9a3f020
...
...
@@ -395,7 +395,26 @@ describe Ci::CreatePipelineService do
result
=
execute_service
expect
(
result
).
to
be_persisted
expect
(
Environment
.
find_by
(
name:
"review/master"
)).
not_to
be_nil
expect
(
Environment
.
find_by
(
name:
"review/master"
)).
to
be_present
end
end
context
'with environment name including persisted variables'
do
before
do
config
=
YAML
.
dump
(
deploy:
{
environment:
{
name:
"review/id1$CI_PIPELINE_ID/id2$CI_BUILD_ID"
},
script:
'ls'
}
)
stub_ci_pipeline_yaml_file
(
config
)
end
it
'skipps persisted variables in environment name'
do
result
=
execute_service
expect
(
result
).
to
be_persisted
expect
(
Environment
.
find_by
(
name:
"review/id1/id2"
)).
to
be_present
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