summaryrefslogtreecommitdiff
path: root/app
diff options
context:
space:
mode:
authorKamil Trzciński <ayufan@ayufan.eu>2015-08-05 15:11:47 +0000
committerKamil Trzciński <ayufan@ayufan.eu>2015-08-05 15:11:47 +0000
commitc790a1d4a19c5b78fb4fe47f1466c842006456c0 (patch)
tree81fb41ab59f5581ce7341f4bb42cb78dbdacb119 /app
parent3ee72501882a48b89f14a58f0c6093d35c7bf9cd (diff)
parentfaee0750d08787993727f10a008c70aa63f8814c (diff)
downloadgitlab-ci-c790a1d4a19c5b78fb4fe47f1466c842006456c0.tar.gz
Merge branch 'yaml-variables' into 'master'
Support yaml variables This MR introduces ability to define variables from YAML. ```yaml variables: DB_NAME: postgres test: script: echo $DB_NAME ``` The variables are passed using the same API as Secure Variables. The API introduces additional parameter: public. All variables defined in YAML are marked as public. The GitLab Runner when detects public variables will pass them to the services. This makes it easy to fine tune linked services to for example define database name. ```yaml services: - postgres variables: POSTGRES_DB: gitlab ``` The above example will run [postgres](https://registry.hub.docker.com/u/library/postgres/) and pass POSTGRES_DB to postgres container making it to create `gitlab` database instead of default `postges`. **Note:** All variables will passed to all service containers. It's not designed to distinguish which variable should go where. /cc @sytses @vsizov @dzaporozhets See merge request !227
Diffstat (limited to 'app')
-rw-r--r--app/models/build.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/app/models/build.rb b/app/models/build.rb
index 11bd967..4f6bf32 100644
--- a/app/models/build.rb
+++ b/app/models/build.rb
@@ -164,7 +164,7 @@ class Build < ActiveRecord::Base
end
def variables
- project.variables
+ yaml_variables + project_variables
end
def duration
@@ -245,4 +245,22 @@ class Build < ActiveRecord::Base
def path_to_trace
"#{dir_to_trace}/#{id}.log"
end
+
+ private
+
+ def yaml_variables
+ if commit.config_processor
+ commit.config_processor.variables.map do |key, value|
+ { key: key, value: value, public: true }
+ end
+ else
+ []
+ end
+ end
+
+ def project_variables
+ project.variables.map do |variable|
+ { key: variable.key, value: variable.value, public: false }
+ end
+ end
end