Search code examples
continuous-integrationgitlabgitlab-cigitlab-ci-runner

GitLab CI/CD Multiple runners


im not sure if this has already been indicated in the docs but i want to know if this is possible

i have 2 runners (1 for building, and 1 for deploying) i have my .gitlab-ci.yml configured to run 2 jobs

job1 to build job2 to deploy

but currently both jobs run in parallel.

what i need is for job2 to wait for job1.

is the above scenario possible?

here is my sample .gitlab-ci.yml

job1: 
  tags: 
    - test1
  script:
    - echo Starting test build
    - ./mvnw clean package -DskipTest
  before_script:
    - cd backend
    - chmod +x mvnw

job2: 
  tags: 
    - deploy
  script:
    - echo Deployment Test
  before_script:
    - echo Pre-Deployment scripts running

thanks


Solution

  • Define 'stages' for the jobs.

    stages:
      - job1
      - job2
    
    job1: 
      tags: 
        - test1
      script:
        - echo Starting test build
        - ./mvnw clean package -DskipTest
      before_script:
        - cd backend
        - chmod +x mvnw
    
    job2: 
      tags: 
        - deploy
      script:
        - echo Deployment Test
      before_script:
        - echo Pre-Deployment scripts running
    

    More details in the documentation.