Search code examples
gitlabgitlab-cigitlab-ci-runner

GITLAB CI Runner tags


I have 2 different stages, but i am using same runner tags for both the stages. so instead of writing tags in both stage can i write only one time somewhere and use that in both stage? This is not working.

before_script:
tags:
  - $RUNNER_LABEL

stages:
  - testE
  - testE2

test1:
  stage: testE
  when: manual
  script:
    - chmod +x gradlew
    - ./gradlew runE2Etests
 # tags:
 #   - $RUNNER_LABEL

test2:
  stage: testE2
  when: manual
  script:
    - chmod +x gradlew
    - ./gradlew runE2Etests
 # tags:
 #   - $RUNNER_LABEL

Solution

  • Perhaps you'd like something like this (extending jobs) You can override the "inherited" parts

    stages:
     - testE
     - testE2
    
    .base-job: &base-job
       tags:
         - $RUNNER_LABEL
       when: manual
       script:
        - chmod +x gradlew
        - ./gradlew runE2Etests
    
    test1: 
      <<: *base-job
      stage: testE
    test2: 
      <<: *base-job
      stage: testE2
    
    #override example - The overridden definition is not concatenated to the base-job, it must be written anew
    test3:
      <<: *base-job
      stage: testE2
      script:
        - chmod +x gradlew
        - ./gradlew runE2Etests
        - echo "DONE"