1

I am trying to add my stages to sub yamls, and i need to share them with other repos so i want them to be in a shared repo

I have this working with include and local in the .gitlab-ci.yml but when I moved the .yml to a different repo to be shard with the others I get Included file .gitlab-ci.yml does not have valid YAML syntax! or Included file https://git.com/group/folder/pipeline/-/raw/main/.static-analysis.yml does not have valid YAML syntax!

I have tried the below to solve the issue.

image: python:3.9

stages:
  - static-analysis

include: 
  - project: 'group/folder/templates/pipeline/'
      ref: main
      file: '.static-analysis.yml'

Included file .gitlab-ci.yml does not have valid YAML syntax!

image: python:3.9

stages:
  - static-analysis

include: 
  - remote: 'https://git.com/group/folder/pipeline/-/raw/main/.static-analysis.yml'

Included file https://git.com/group/folder/pipeline/-/raw/main/.static-analysis.yml does not have valid YAML syntax!

I have got this to work with the following, but this will not share with the other repos

image: python:3.9

stages:
  - static-analysis

include: 
  - local: '.static-analysis.yml'

.static-analysis.yml

job:
  stage: static-analysis
  script:
    - echo "test"
stevied
  • 11
  • 2

2 Answers2

1

Included file https://git.com/group/folder/pipeline/-/raw/main/.static-analysis.yml does not have valid YAML syntax!

This is most likely because your project does not have public visibility. You can only include files using remote: that don't require any authentication to access.

If your shared project is in the same gitlab instance, the correct method is to use include: project:

include:
  project: mygroup/myproject
  file: 
    - path/to/gitlab-ci.yml
    - path/to/another/ci.yml
sytech
  • 29,298
  • 3
  • 45
  • 86
0

found my bug there where spaces before ref and file. but still cant use remote

image: python:3.9

stages:
  - static-analysis
  - build

include: 
  - project: 'group/folder/templates/pipeline/'
    ref: main
    file: '.static-analysis.yml' 
  - project: 'group/folder/templates/pipeline/'
    ref: main
    file: '.build.yml'
stevied
  • 11
  • 2