tell me the best way to create a shared runner in gitlab that does not depend on the os?

Steps to register a Shared Runner:

Pre-requisite: Gitlab-Runner should have been installed. Follow this document for Installing Runner

  • Login to Gitlab. Go to Admin Area >> Overview >> Runners >> Set up a shared Runner manually

enter image description here

  • Login to the server where runner is installed, either with root user or the user with which you have installed runner (say gitlab-runner). Here, we are registering the runner using root user. Run the below command:

    gitlab-runner register

  • Fill the following details according to your setup:

    • Please enter the gitlab-ci coordinator URL: https://example.com/gitlab/

      (Look for the url in the gitlab under Set up a shared Runner manually)

    • Please enter the gitlab-ci token for this runner: jiRS-3KxGaEdkLo6tToZ

      (Look for the token in the gitlab under Set up a shared Runner manually )

    • Please enter the gitlab-ci description for this runner: my-first-shred-runner

      (Enter any name for the runner)

    • Please enter the gitlab-ci tags for this runner (comma separated): ci-shared,ci-task

      (Enter any tags you want to associate with the runner)

    • Please enter the executor: docker-ssh, parallels, virtualbox, docker+machine, kubernetes, custom, docker, docker-ssh+machine, shell, ssh: shell

      (Enter the executor you need the runner to use, depending on choice of executor you will get other options to fill. Please go through documents of executors )

Now, you can see the message runner has been registered.

enter image description here

You can verify the same in the Gitlab. Go to Gitlab, Admin Area >> Overview >> Runners >> Set up a shared Runner manually and you can see the runner has been registered with name my-first-shred-runner

enter image description here

Steps to enable Shared Runner for a project in Gitlab:

  1. Go to a Project in Gitlab.
  2. Then, in the project page, Settings >> CI/CD >> Runners >> Shared Runners
  3. Then, click on Enable shared runners. Now, you can use the shared runner for Gitlab CI/CD.
  4. Use the tags associated with shared runner in .gitlab-ci.yml, so that the jobs will run using shared runner.

enter image description here

Change the tags in .gitlab-ci.yml

image: jangrewe/gitlab-ci-android

stages:
  - build

before_script:
  - export GRADLE_USER_HOME=$(pwd)/.gradle
  - chmod +x ./gradlew

cache:
  key: ${CI_PROJECT_ID}
  paths:
    - .gradle/

build:
  stage: build
  tags:
    - ci-shared
  script:
    - ./gradlew assembleDevelopment assembleProduction assembleStaging
  artifacts:
    paths:
      - app/build/outputs/

Steps to register Specific Runner:

  1. Login to Gitlab. Go to the Project and then Settings >> CI/CD >> Runners >> Set up a specific Runner manually
  2. Next, follow the same steps from step 2 as given above for Registering Shared Runner

enter image description here

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top