Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use `extends` with `gitlab-runner exec`

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?

like image 573
Fábio Roberto Teodoro Avatar asked Oct 02 '19 16:10

Fábio Roberto Teodoro


People also ask

What is extends in GitLab?

Here is the definition from GitLab documentation: extends defines entry names that a job that uses extends inherits from. It's an alternative to using YAML anchors and is a little more flexible and readable. So, when is it useful? It is useful when you want to be DRY and keep your setup cleanly.

What is executor for GitLab runner?

The Kubernetes executor allows you to use an existing Kubernetes cluster for your builds. The executor will call the Kubernetes cluster API and create a new Pod (with build container and services containers) for each GitLab CI job.

Why GitLab is better than Jenkins?

While Jenkins boasts of a large plugin shelf, Gitlab is a comprehensive DevOps tool. While multiple plugins do your job efficiently, integration and management of these plugins might become a challenge when the project scales up. Gitlab offers SLA support.


1 Answers

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.

like image 141
Rafik Avtoyan Avatar answered Oct 19 '22 21:10

Rafik Avtoyan