Gitlab-CI only:variables doesn't work as intended
Summary
Gitlab-CI's only.variables gets validated when it should not
Steps to reproduce
Here is a sample job configuration:
stages:
- run
start-staging-1:
stage: run
image: python:latest
only:
variables:
- $ACTION == "start"
- $ENV == "staging-1"
script:
- pip install awscli
- aws ec2 start-instances --instance-ids ...
stop-staging-1:
stage: run
image: python:latest
only:
variables:
- $ACTION == "stop"
- $ENV == "staging-1"
script:
- pip install awscli
- aws ec2 stop-instances --instance-ids ...
I then trigger jobs using schedules with the following ENV vars:
What is the current bug behavior?
The current observed behavior is that at each run, both the start and stop jobs are launched.
What is the expected correct behavior?
Only the job matching the ACTION should be started
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: Traceback (most recent call last): File "/usr/bin/lsb_release", line 28, in import lsb_release ImportError: No module named 'lsb_release' Current User: git Using RVM: no Ruby Version: 2.5.3p105 Gem Version: 2.7.6 Bundler Version:1.16.6 Rake Version: 12.3.2 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.5 Go Version: unknownGitLab information Version: 11.9.8 Revision: 48528bc Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: https:// HTTP Clone URL: https:///some-group/some-project.git SSH Clone URL: ssh://git@:2233/some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers: azure_oauth2
GitLab Shell Version: 8.7.1 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 >= 8.7.1 ? ... OK (8.7.1) Running /opt/gitlab/embedded/service/gitlab-shell/bin/check Check GitLab API access: OK Redis available via internal API: OK
Access to /var/opt/gitlab/.ssh/authorized_keys: 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: ... --all yes-- Redis version >= 2.8.0? ... yes Ruby version >= 2.3.5 ? ... yes (2.5.3) Git version >= 2.18.0 ? ... yes (2.18.1) Git user has default SSH configuration? ... no Try fixing it: mkdir ~/gitlab-check-backup-1555839823 sudo mv /var/opt/gitlab/.ssh/authorized_keys.backup ~/gitlab-check-backup-1555839823 For more information see: doc/ssh/README.md in section "SSH on the GitLab server" Please fix the error above and rerun the checks. Active users: ... 39
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
No, but ugly workaround for now is to add in the script section:
if [ $ACTION != "start" ] || [ $ENV != "staging-1" ]; then exit 0; fi
