Search code examples
gitlabgitlab-ci-runner

Gitlab runner fails to start. This job is stuck because you don't have any active runners online with any of these tags assigned to them: ios


I have a remote runner:

ci$ gitlab-runner --version Version: 12.2.0

The .gitlab-ci.yml :

stages:
  - build
  - deploy

variables:
  LANG: "en_US.UTF-8"
  LC_ALL: "en_US.UTF-8"

build:
  tags:
    - ios
  stage: build
  script:
    - bundle exec fastlane build
  except:
    - develop
    - master
    - /^rc\/.*$/
  environment:
    name: production

deploy:
  tags:
    - ios
  stage: deploy
  before_script:
    - 'which ssh-agent || ( apt-get update -y && apt-get install openssh-client git -y )'
    - eval $(ssh-agent -s)
    - echo "$SSH_PRIVATE_KEY" | tr -d '\r' | ssh-add -
    - mkdir -p ~/.ssh
    - chmod 700 ~/.ssh
    - ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
    - chmod 644 ~/.ssh/known_hosts
    - ssh -vv git@gitlab.com
    - git config --global user.email "email@email.com"
    - git config --global user.name "username"
    - git branch
    - git branch -r
  script:
    - bundle exec fastlane deploy
  only:
    - develop
    - master
    - /^rc\/.*$/
  environment:
    name: production

post:
  stage: .post
  when: always
  script:
    - bundle exec fastlane clear_data_CI

Gitlab CI fails to run, drops this warning first:

This job is stuck because the project doesn't have any runners online assigned to it.

Go to Runners page And later:

There has been a timeout failure or the job got stuck. Check your timeout limits or try again

So tags are added, but it stopped running. Remote runner is working properly. Any issues?


Solution

  • You have to make sure that the remote runner you are referring to is:

    • Actually running
    • Listed as an activated runner in your project's Runners section
    • Configured to follow/listen to the same tags

    Go to your repo's Gitlab project settings. Then find the section for CI / CD > Runners. You should see something like the image below:

    enter image description here

    Here we see that there is a runner (df51f559) configured for the project, and it is running (green). If your repo's .gitlab-ci.yml is using tags, then that runner must also have the same tags. So here, if your job is expecting a runner with ios tag, then this UI should also show the runner to have an ios tag.

    You can verify the runner token using gitlab-runner verify or list:

    root@buildpc:~# gitlab-runner verify
    ...
    Verifying runner... is alive             runner=df51f559
    
    root@buildpc:~# gitlab-runner list
    my-runner                                Executor=docker Token=df51f55995e68cccb3ada8c1458ec7 URL=http://192.168.1.61/
    

    Here my-runner's

    • Token must match the token displayed in the Runners page
    • URL must match the base URL of your Gitlab project

    If you can't see an activated runner, that section has instructions on how to register a new runner for your project. You can also refer to Gitlab's Registering Runners help docs.

    If you have admin access to your Gitlab instance, you can also go to the Admin dashboard, Runners, select a runner from the available ones, then manually add it to your project. You can also edit the tags.

    enter image description here

    Lastly, as mentioned in the comments, if you originally had no active runners then you successfully added one, you need to restart the job. AFAIK, when a job gets stuck because there is no runner, it does not automatically resume when a runner becomes available. You'll have to manually retry or re-trigger the job.