Skip to content

workflow:rules variables can not access passed variables from upstream and trigger variables

Summary

workflow:rules (as described in https://docs.gitlab.com/12.7/ee/ci/yaml/README.html#workflowrules) does not work properly with triggered pipelines and passing variables.

Steps to reproduce

Create upstream pipeline:

test multiproject:
  trigger: workflow/upstream
  variables:
    MYVAR: examplevalue
    
test trigger api:
  script:
    - "curl -X POST -F token=<your token here> -F ref=master -F variables[MYVAR]=examplevalue https://gitlab.com/api/v4/projects/123/trigger/pipeline"

Create downstream pipeline:

workflow:
  rules:
    - if: '$MYVAR'
      when: always
    - when: never

job1:
  script:
    - echo $MYVAR

Example Project

Example projects on gitlab.com: https://gitlab.com/workflow5/downstream https://gitlab.com/workflow5/upstream

What is the current bug behavior?

Job 'test multiproject' will be stuck. Job 'test trigger api' will have '{"message":{"base":["Pipeline filtered out by workflow rules."]}}' in output and no pipeline triggered.

What is the expected correct behavior?

Downstream Pipeline is triggered properly with defined variables.

Output of checks

This bug happens on GitLab.com and self-hosted GitLab Enterprise 12.7.5.

Results of GitLab environment info

Expand for output related to GitLab environment info

System information System: RedHatEnterpriseServer 7.7 Proxy: http_proxy: http://1.2.3.4:8080 https_proxy: http://1.2.3.4:8080 no_proxy: localhost,127.0.0.1 Current User: git Using RVM: no Ruby Version: 2.6.5p114 Gem Version: 2.7.10 Bundler Version:1.17.3 Rake Version: 12.3.3 Redis Version: 5.0.7 Git Version: 2.24.1 Sidekiq Version:5.2.7 Go Version: unknown

GitLab information Version: 12.7.5-ee Revision: 19edff260da Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: PostgreSQL DB Version: 10.9 URL: https://sanitazed.com HTTP Clone URL: https://sanitazed.com/some-group/some-project.git SSH Clone URL: sanitazed@sanitazed.com:some-group/some-project.git Elasticsearch: no Geo: no Using LDAP: yes Using Omniauth: yes Omniauth Providers: saml

GitLab Shell Version: 11.0.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

Results of GitLab application Check

Expand for output related to the GitLab application check

Checking GitLab subtasks ...

Checking GitLab Shell ...

GitLab Shell: ... GitLab Shell version >= 11.0.0 ? ... OK (11.0.0) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Internal API available: OK Redis available via internal API: OK gitlab-shell self-check successful

Checking GitLab Shell ... Finished

Checking Gitaly ...

Gitaly: ... default ... OK

Checking Gitaly ... Finished

Checking Sidekiq ...

Sidekiq: ... Running? ... yes Number of Sidekiq processes ... 1

Checking Sidekiq ... Finished

Checking Incoming Email ...

Incoming Email: ... Reply by email is disabled in config/gitlab.yml

Checking Incoming Email ... Finished

Checking LDAP ...

LDAP: ... Server: ldapmain not verifying SSL hostname of LDAPS server 'sanitazed.com:636' LDAP authentication... Success LDAP users with access to your GitLab server (only showing the first 100 results) not verifying SSL hostname of LDAPS server 'sanitazed.com:636' not verifying SSL hostname of LDAPS server 'sanitazed.com:636' User output sanitized. Found 44 users of 100 limit.

Checking LDAP ... Finished

Checking GitLab App ...

Git configured correctly? ... yes Database config exists? ... yes All migrations up? ... yes Database contains orphaned GroupMembers? ... no GitLab config exists? ... yes GitLab config up to date? ... yes Log directory writable? ... yes Tmp directory writable? ... yes Uploads directory exists? ... yes Uploads directory has correct permissions? ... yes Uploads directory tmp has correct permissions? ... yes Init script exists? ... skipped (omnibus-gitlab has no init script) Init script up-to-date? ... skipped (omnibus-gitlab has no init script) Projects have namespace: ... 1/1 ... yes 3/4 ... yes 13/6 ... yes 13/7 ... yes 17/8 ... yes 15/11 ... yes 15/12 ... yes 23/13 ... yes 23/14 ... yes 23/15 ... yes 23/16 ... yes 25/18 ... yes 23/19 ... yes 23/21 ... yes 23/22 ... yes 15/24 ... yes 23/25 ... yes 13/26 ... yes 13/27 ... yes 15/29 ... yes 35/30 ... yes 15/31 ... yes 27/32 ... yes 23/33 ... yes 23/34 ... yes 15/37 ... yes 13/38 ... yes 15/39 ... yes 15/40 ... yes 13/41 ... yes 4/42 ... yes 13/43 ... yes 13/44 ... yes 50/45 ... yes 27/46 ... yes 27/47 ... yes Redis version >= 2.8.0? ... yes Ruby version >= 2.5.3 ? ... yes (2.6.5) Git version >= 2.22.0 ? ... yes (2.24.1) Git user has default SSH configuration? ... yes Active users: ... 7 Is authorized keys file accessible? ... yes Elasticsearch version 5.6 - 6.x? ... skipped (elasticsearch is disabled)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Edited by Furkan Ayhan