Using refspec of HEAD fails for pipeline triggered CI job
Summary
Using refspec variable value of 'HEAD' fails to run a pipeline triggered CI job
Steps to reproduce
Submit a web request with ref=HEAD and observe it fails on 10.7 with 400, 'Bad Request'.
If a branch name is specified, it succeeds. Note that HEAD does point to the branch name which works with ref parameter.
Example Project
None.
What is the current bug behavior?
Failing to run job when using ref=HEAD.
My existing cronjob which called the trigger was failing to run after upgrading from 10.4 to 10.7 Gitlab CE releases.
What is the expected correct behavior?
I think it should work as HEAD should always represent the tip of the current branch. Perhaps it's not great to use as "stable" ref, if that's the case it should be documented or better error message should be returned.
Relevant logs and/or screenshots
I used Python request library to make the calls. I've add some prints to dump the request info. Redacting some internal info.
Working call with full branch name.
POST http://gitlab-test.mydomain.com/api/v4/projects/6/trigger/pipeline
Content-Length: 196
Content-Type: application/x-www-form-urlencoded
variables%5BPACKAGE_DISTRO%5D=Ubuntu_16.04_64&variables%5BMYSCALEVAR%5D=2&token=<mytoken>&ref=dev%2Fusername%2Fgitlab-test-testbot&variables%5BPACKAGE_VERSION%5D=1.2.3.4
(201, 'Created')
Failing call with 'HEAD' ref.
POST http://gitlab-test.mydomain.com/api/v4/projects/6/trigger/pipeline
Content-Length: 163
Content-Type: application/x-www-form-urlencoded
variables%5BPACKAGE_DISTRO%5D=Ubuntu_16.04_64&variables%5BMYSCALEVAR%5D=2&token=<mytoken>&ref=HEAD&variables%5BPACKAGE_VERSION%5D=1.2.3.4
(400, 'Bad Request')
Output of checks
None.
Results of GitLab environment info
System information
System: Ubuntu 16.04
Current User: git
Using RVM: no
Ruby Version: 2.3.6p384
Gem Version: 2.6.13
Bundler Version:1.13.7
Rake Version: 12.3.0
Redis Version: 3.2.11
Git Version: 2.14.3
Sidekiq Version:5.0.5
Go Version: unknown
GitLab information
Version: 10.7.3
Revision: 2555d6c
Directory: /opt/gitlab/embedded/service/gitlab-rails
DB Adapter: postgresql
URL: http://gitlab-test.mydomain.com
HTTP Clone URL: http://gitlab-test.mydomain.com/some-group/some-project.git
SSH Clone URL: git@gitlab-test.mydomain.com:some-group/some-project.git
Using LDAP: no
Using Omniauth: no
GitLab Shell
Version: 7.1.2
Repository storage paths:
- default: /var/opt/gitlab/git-data/repositories
Hooks: /opt/gitlab/embedded/service/gitlab-shell/hooks
Git: /opt/gitlab/embedded/bin/git
Results of GitLab application 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 Sidekiq ...
Running? ... yes
Number of Sidekiq processes ... 1
Checking Sidekiq ... Finished
Reply by email is disabled in config/gitlab.yml
Checking LDAP ...
LDAP is disabled in config/gitlab.yml
Checking LDAP ... Finished
Checking GitLab ...
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: ...
4/1 ... yes
4/2 ... yes
6/4 ... yes
5/6 ... yes
Redis version >= 2.8.0? ... yes
Ruby version >= 2.3.5 ? ... yes (2.3.6)
Git version >= 2.9.5 ? ... yes (2.14.3)
Git user has default SSH configuration? ... yes
Active users: ... 4
Checking GitLab ... Finished
Possible fixes
I did a compare between 10.4 and 10.7 on Gitlab.com and only saw things related to scheduling.