Variable precedence in bridge multi-project pipeline

Summary

Variables precedence in bridge pipelines is not documented anywhere and currently it's trial&error for users to figure it out. My expected behaviour was that locally (downstream) defined variables will have precedence over upstream defined variables. But that is not the case.

Steps to reproduce

See example projects below

Example Project

upstream project

variables:
    STATIC_GLOBAL: I am global
    
downstream:
    variables:
        STATIC_JOB: I am static
    trigger: user/downstream

downstream project

variables:
    STATIC_GLOBAL: I am global downstream
    STATIC_JOB: I am static downstream
    
build:
    script:
        - echo "$STATIC_GLOBAL"
        - echo "$STATIC_JOB"

What is the current bug behavior?

Skipping Git submodules setup
$ echo "$STATIC_GLOBAL"
I am global
$ echo "$STATIC_JOB"
I am static
Job succeeded

What is the expected correct behavior?

Skipping Git submodules setup
$ echo "$STATIC_GLOBAL"
I am global downstream
$ echo "$STATIC_JOB"
I am static downstream
Job succeeded

Results of GitLab environment info

System information
System:         RedHatEnterpriseServer 7.6
Proxy:          no
Current User:   git
Using RVM:      no
Ruby Version:   2.5.3p105
Gem Version:    2.7.9
Bundler Version:1.17.3
Rake Version:   12.3.2
Redis Version:  3.2.12
Git Version:    2.21.0
Sidekiq Version:5.2.7
Go Version:     unknown

GitLab information
Version:        11.11.5-ee
Revision:       9bb97b4d478
Directory:      /opt/gitlab/embedded/service/gitlab-rails
DB Adapter:     PostgreSQL
DB Version:     10.7
URL:            removed
HTTP Clone URL: removed
SSH Clone URL:  removed
Elasticsearch:  no
Geo:            no
Using LDAP:     yes
Using Omniauth: yes
Omniauth Providers: saml

GitLab Shell
Version:        9.1.0
Repository storage paths:
- default:      /var/opt/gitlab/git-data/repositories
GitLab Shell path:              /opt/gitlab/embedded/service/gitlab-shell
Git:            /opt/gitlab/embedded/bin/git

Possible fixes

Definatelly document variable precedence so it's clear how it will behave without users do trial&error. To be consistent with behaviour with most used programming languages locally defined variables should take precedence.

Assignee Loading
Time tracking Loading