How to use `extends` with `gitlab-runner exec`
Asked Answered
A

2

7

I have a .gitlab-ci.yaml with the extends directive, which works on the gitlab-ci, but I cannot test it with gitlab-runner exec, it looks like the extends is ignored by gitlab-runner.

I have two files, like:

# .2extend.yml
.job2extend:
  image: some/docker/img
  stage: test
  script:
    - echo do things with "${myvar}"

and

# .gitlab-ci.yml
include:
  - project: 'project/to/extend'
    ref: master
    file: '.2extend.yml'

myjob:
  extends: .job2extend
  variables:
    myvar: 'My Variable'

This is the error I'm having:

$ gitlab-runner exec docker myjob
Runtime platform                                    arch=amd64 os=linux pid=29785 revision=45d9c1d6 version=12.4.0~beta.1935.g45d9c1d6
FATAL: missing 'script' for job

The job I am extending from, have both script and image directives.

I have come to this issue which has the same problem as I do.

So, there is workaround to do this while the issue is not solved?

Apothecium answered 2/10, 2019 at 16:28 Comment(0)
A
2

It seems gitlab-runner exec has some limitations, before using this functional please check with Limitations of gitlab-runner exec

As you can see for now extends is not listed in the table.

Ammieammine answered 25/10, 2021 at 13:9 Comment(0)
F
1

I suppose this is because the .gitlab-ci.yml file of the project does not have a script block at the root level (for example like this)

# .gitlab-ci.yml    
include:
  - project: 'project/to/extend'
    ref: master
    file: '.2extend.yml'

myjob:
  extends: .job2extend
  variables:
    myvar: 'My Variable'

script:
  - myjob
Flavin answered 22/9, 2021 at 5:3 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.