Error on include targeting file in a different repository
Summary
I want to use include in my .gitlab-ci.yml file to include a template stored in an internal repository within the same group. This is representative of my structure:
internal_group
|-> template_repo
| |-> .gitlab-ci-template.yml
|-> code_repo
| |-> .gitlab-ci.yml
where code_repo/.gitlab-ci.yml has the following include structure:
include:
- project: 'internal_group/template_repo'
file: '/.gitlab-ci-template.yml
stages:
- custom_stage1
- custom_stage2
variables:
VAR1: "VAR1"
VAR2: "VAR2"
VAR3: "VAR3"
VAR4: "VAR4"
VAR5: "VAR5"
Steps to reproduce
Set up the above structure, where the group and repositories have internal visibility. Go to the CI Lint page from code_repo, and enter a yaml which defines an include from the template_repo/.gitlab-ci-template.yml.
Example Project
I tried to create a group/repo structure which mirrored our local structure, but I am not getting the error on the gitlab.com instance. I see that gitlab.com is running GitLab 11.7 RC1 whereas I am running GitLab 11.6.3 (gitlab-ce@bc9391c294422742a7c0f904cbac4e841a73ae9e). The project is located here.
What is the current bug behavior?
CI Lint page gives 500 error and jobs fail with Invalid YAML error.
Exact error message from pushing a commit is:
Found errors in your .gitlab-ci.yml:
- Undefined error
What is the expected correct behavior?
CI Lint validates yaml and jobs run on pushed commit
Relevant logs and/or screenshots
After submitting the contents of .gitlab-ci.yml to the CI Linter, this shows up in /var/log/gitlab/gitlab-rails/production.log:
Started POST "/group_name/repo_name/-/ci/lint" for 127.0.0.1 at 2019-01-10 10:37:36 -0500
Processing by Projects::Ci::LintsController#create as HTML
Parameters: {"utf8"=>"✓", "authenticity_token"=>"[FILTERED]", "content"=>"[FILTERED]", "namespace_id"=>"group_name", "project_id"=>"repo_name"}
Completed 500 Internal Server Error in 12ms (ActiveRecord: 1.1ms)
TypeError (no implicit conversion of Hash into String):
lib/gitlab/ci/config/external/file/base.rb:24:in `basename'
lib/gitlab/ci/config/external/file/base.rb:24:in `invalid_extension?'
lib/gitlab/ci/config/external/file/base.rb:54:in `validate_location!'
lib/gitlab/ci/config/external/file/base.rb:48:in `validate!'
lib/gitlab/ci/config/external/file/base.rb:20:in `initialize'
lib/gitlab/ci/config/external/file/local.rb:17:in `initialize'
lib/gitlab/ci/config/external/mapper.rb:26:in `new'
lib/gitlab/ci/config/external/mapper.rb:26:in `build_external_file'
lib/gitlab/ci/config/external/mapper.rb:15:in `block in process'
lib/gitlab/ci/config/external/mapper.rb:15:in `map'
lib/gitlab/ci/config/external/mapper.rb:15:in `process'
lib/gitlab/ci/config/external/processor.rb:12:in `initialize'
lib/gitlab/ci/config.rb:86:in `new'
lib/gitlab/ci/config.rb:86:in `process_external_files'
lib/gitlab/ci/config.rb:78:in `build_config'
lib/gitlab/ci/config.rb:13:in `initialize'
lib/gitlab/ci/yaml_processor.rb:13:in `new'
lib/gitlab/ci/yaml_processor.rb:13:in `initialize'
lib/gitlab/ci/yaml_processor.rb:85:in `new'
lib/gitlab/ci/yaml_processor.rb:85:in `validation_message'
app/controllers/projects/ci/lints_controller.rb:11:in `create'
lib/gitlab/i18n.rb:55:in `with_locale'
lib/gitlab/i18n.rb:61:in `with_user_locale'
app/controllers/application_controller.rb:420:in `set_locale'
lib/gitlab/middleware/multipart.rb:103:in `call'
lib/gitlab/request_profiler/middleware.rb:16:in `call'
lib/gitlab/middleware/go.rb:19:in `call'
lib/gitlab/etag_caching/middleware.rb:13:in `call'
lib/gitlab/middleware/correlation_id.rb:16:in `block in call'
lib/gitlab/correlation_id.rb:15:in `use_id'
lib/gitlab/middleware/correlation_id.rb:15:in `call'
lib/gitlab/middleware/read_only/controller.rb:40:in `call'
lib/gitlab/middleware/read_only.rb:18:in `call'
lib/gitlab/middleware/basic_health_check.rb:25:in `call'
lib/gitlab/request_context.rb:20:in `call'
lib/gitlab/metrics/requests_rack_middleware.rb:29:in `call'
lib/gitlab/middleware/release_env.rb:13:in `call'
Output of checks
(Not sure what to put here)
Results of GitLab environment info
Expand for output related to GitLab environment info
System information System: 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.1 Redis Version: 3.2.12 Git Version: 2.18.1 Sidekiq Version:5.2.3 Go Version: unknownGitLab information Version: 11.6.3 Revision: bc9391c Directory: /opt/gitlab/embedded/service/gitlab-rails DB Adapter: postgresql URL: http://gitlab.bms HTTP Clone URL: http://gitlab.bms/some-group/some-project.git SSH Clone URL: git@gitlab.bms:some-group/some-project.git Using LDAP: no Using Omniauth: yes Omniauth Providers:
GitLab Shell Version: 8.4.3 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
Expand for output related to the GitLab application check
Checking GitLab subtasks ...Checking GitLab Shell ...
GitLab Shell: ... GitLab Shell version >= 8.4.3 ? ... OK (8.4.3) 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: ... 3/1 ... yes 4/3 ... yes 6/4 ... yes 6/5 ... yes 6/6 ... yes 6/7 ... yes 6/8 ... yes 6/9 ... yes 6/10 ... yes 6/12 ... yes 7/13 ... yes 7/14 ... yes 7/15 ... yes 7/16 ... yes 7/18 ... yes 6/19 ... yes 6/20 ... yes 4/22 ... yes 6/23 ... yes 6/24 ... yes 12/25 ... yes 12/26 ... yes 12/27 ... yes 12/28 ... yes 12/29 ... yes 12/30 ... yes 12/31 ... yes 12/32 ... yes 12/33 ... yes 12/34 ... yes 12/35 ... yes 12/36 ... yes 12/37 ... yes 12/38 ... yes 12/39 ... yes 12/40 ... yes 12/41 ... yes 12/42 ... yes 12/43 ... yes 12/44 ... yes 12/45 ... yes 12/46 ... yes 12/47 ... yes 12/48 ... yes 12/49 ... yes 12/50 ... yes 12/51 ... yes 12/52 ... yes 12/53 ... yes 6/54 ... yes 12/55 ... yes 12/56 ... yes 12/57 ... yes 4/58 ... yes 7/59 ... yes 6/60 ... yes 6/61 ... yes 12/62 ... 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? ... yes Active users: ... 7
Checking GitLab App ... Finished
Checking GitLab subtasks ... Finished
Possible fixes
I did what little investigation I could. This is located at line 24 of /opt/gitlab/embedded/service/gitlab-rails/lib/gitlab/ci/config/external/file/base.rb:
!::File.basename(location).match(YAML_WHITELIST_EXTENSION)
The only thing I can think of is the location parameter is being passed as an array (possibly an array of project and filename?).
Let me know if there is any more information I can provide. Thanks!