Skip to content

Merge request pipelines are unintentionally created for non-merge request related variables used in rules:if conditions

Everyone can contribute. Help move this issue forward while earning points, leveling up and collecting rewards.

Summary

As per Pipelines for Merge Requests, pipelines are triggered for merge requests only when we trigger them based on only or rules keywords.

In the case of rules keyword, we need to use some merge request related variables to create a detached pipeline. For example:

  • if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
  • if: $CI_MERGE_REQUEST_IID

etc..

But, I observed that a detached pipeline is created for some other variables matching the rules as well, such as if: '$CI_COMMIT_TAG == null', if: $CI_PROJECT_NAME etc.

Steps to reproduce

  • Create a .gitlab-ci.yml with below contents:
stages:
  - test
.rules:
  rules:
   # - if: $CI_PROJECT_NAME
    - if: '$CI_COMMIT_TAG == null'
deploy:
  stage: test
  extends:
    - .rules
  variables:
    SAMPLE: hello
  script:
    - echo $CI_COMMIT_TAG
  • Create a branch from master, commit something.
  • Create a merge request from new branch to master. You'll find a detached pipeline starting.
  • You can also reproduce it by commenting out CI_COMMIT_TAG condition and uncommenting CI_PROJECT_NAME condition.

What is the current bug behavior?

A merge request pipeline is created unintentionally for some non-merge requested related variables in rules:if conditions.

What is the expected correct behavior?

A merge request pipeline should be created only for merge request related variables in rules:if conditions.

If some variables, that are not evidently merge request related, make the pipeline run under merge request context, we need to clearly specify them in the docs.

Output of checks

Results of GitLab environment info

Expand for output related to GitLab environment info

System information
System:		Ubuntu 18.04
Proxy:		no
Current User:	git
Using RVM:	no
Ruby Version:	2.7.2p137
Gem Version:	3.1.4
Bundler Version:2.1.4
Rake Version:	13.0.3
Redis Version:	5.0.9
Git Version:	2.29.0
Sidekiq Version:5.2.9
Go Version:	unknown

GitLab information
Version:	13.8.1-ee
Revision:	e10a21e66ce
Directory:	/opt/gitlab/embedded/service/gitlab-rails
DB Adapter:	PostgreSQL
DB Version:	12.4
URL:		https://psureshbabu-gitlab.sr.gitlab.support
HTTP Clone URL:	https://psureshbabu-gitlab.sr.gitlab.support/some-group/some-project.git
SSH Clone URL:	git@psureshbabu-gitlab.sr.gitlab.support:some-group/some-project.git
Elasticsearch:	yes
Geo:		no
Using LDAP:	no
Using Omniauth:	yes
Omniauth Providers:

GitLab Shell
Version:	13.15.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 >= 13.15.0 ? ... OK (13.15.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: ... LDAP is disabled in config/gitlab.yml

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: ... 2/1 ... yes 1/2 ... yes 1/3 ... yes 1/4 ... yes 5/7 ... yes 1/9 ... yes 4/10 ... yes 6/11 ... yes 6/12 ... yes 1/13 ... yes 1/14 ... yes 1/16 ... yes 13/17 ... yes 13/18 ... yes 1/19 ... yes 6/20 ... yes 1/21 ... yes 1/22 ... yes 1/23 ... yes 1/24 ... yes 1/25 ... yes 1/26 ... yes 1/27 ... yes 1/28 ... yes 1/29 ... yes 1/30 ... yes 1/31 ... yes 1/32 ... yes 1/33 ... yes 14/34 ... yes 1/35 ... yes 1/36 ... yes 1/37 ... yes 1/38 ... yes 1/39 ... yes 1/40 ... yes 1/41 ... yes 1/42 ... yes 1/43 ... yes 1/44 ... yes 1/45 ... yes 1/46 ... yes 1/47 ... yes 1/48 ... yes 1/49 ... yes 1/50 ... yes 1/51 ... yes 1/52 ... yes 1/53 ... yes 1/54 ... yes 1/55 ... yes 1/56 ... yes 15/57 ... yes 1/58 ... yes 1/59 ... yes Redis version >= 4.0.0? ... yes Ruby version >= 2.7.2 ? ... yes (2.7.2) Git version >= 2.29.0 ? ... yes (2.29.0) Git user has default SSH configuration? ... yes Active users: ... 3 Is authorized keys file accessible? ... yes GitLab configured to store new projects in hashed storage? ... yes All projects are in hashed storage? ... yes Elasticsearch version 7.x (6.4 - 6.x deprecated to be removed in 13.8)? ... Exception: Connection refused - Connection refused - connect(2) for "127.0.0.1" port 9200 (localhost:9200)

Checking GitLab App ... Finished

Checking GitLab subtasks ... Finished

Possible fixes

Edited by 🤖 GitLab Bot 🤖