Using include keyword with tags

Hi,

I’ve been experimenting with using the include keyword in my CI pipeline to include templates that come with GitLab, such as code analysis and dependency scanning.

However the way the runners are configure in my system require the tags keyword to be used.

Is there anyway to include a template and tell it to use a particular tag?

Thank you.

Hey @Cynan, welcome to the forum!

You can certainly do this by just defining the job that you’re including again after the include. For example, if I want to include the Code Quality job from Auto DevOps but ensure that its only run on a Runner tagged with linux I’d do the following.

include:
- template: Jobs/Code-Quality.gitlab-ci.yml

code_quality:
 tags:
   - linux

I hope that helps!

Brilliant.

Thank you!

1 Like

@Tristan, will this work if I’m including meta-job together with job :

.rc:
  stage: release
  when: manual
  only:
    - master

MAJOR RC:
  extends:
    - .rc
  script:
    - ./gradlew -Prelease.scope=major clean candidate

MINOR RC:
  extends:
    - .rc
  script:
    - ./gradlew -Prelease.scope=minor clean candidate

and then :

include:
- remote: https://myserver/project/raw/release.yml

.rc:
 tags:
   - linux

@jvmlet That syntax looks good to me, so I believe that should work, yes.