Jobs are stalled and waiting for resource because variable $CI_COMMIT_BRANCH is not populated in rules
Summary
Jobs are stalled and waiting for resource because $CI_COMMIT_BRANCH
is not populated in the rules:variables
"This job is waiting for resource: story/$CI_COMMIT_BRANCH"
Steps to reproduce
- Create two branches
branch_1
andbranch_2
- Create a pipeline that runs some code like:
stages:
- deploy
deploy_backend:
stage: deploy
script:
- echo "${CI_COMMIT_BRANCH}"
- sleep 100
rules:
- if: $CI_COMMIT_BRANCH =~ /^branch_[12]$/
when: on_success
variables:
DEPLOY_VARIABLE: story/$CI_COMMIT_BRANCH
ENV_URL: https://$CI_COMMIT_BRANCH.test.example.com
resource_group: $DEPLOY_VARIABLE
interruptible: false
allow_failure: false
environment:
name: $DEPLOY_VARIABLE
url: $ENV_URL
- Push this code to both branches
- The pipeline that ran later will be in the
Waiting
state with a messageThis job is waiting for resource: story/$CI_COMMIT_BRANCH
Example Project
https://gitlab.com/daniil18/gitlab-stalled
What is the current bug behavior?
Variable $CI_COMMIT_BRANCH
is not populated therefore resource story/$CI_COMMIT_BRANCH
is blocking all other branches that ran at the same time.
What is the expected correct behavior?
Variable CI_COMMIT_BRANCH
is populated in rules:variables
and two resource groups created story/branch_1
and story/branch_2
that are able to run simultaneously.
Relevant logs and/or screenshots
Output of checks
This bug happens on GitLab.com
Results of GitLab environment info
Expand for output related to GitLab environment info
(For installations with omnibus-gitlab package run and paste the output of: `sudo gitlab-rake gitlab:env:info`) (For installations from source run and paste the output of: `sudo -u git -H bundle exec rake gitlab:env:info RAILS_ENV=production`)
Results of GitLab application Check
Expand for output related to the GitLab application check
(For installations with omnibus-gitlab package run and paste the output of:
sudo gitlab-rake gitlab:check SANITIZE=true
)(For installations from source run and paste the output of:
sudo -u git -H bundle exec rake gitlab:check RAILS_ENV=production SANITIZE=true
)(we will only investigate if the tests are passing)