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
Asked Answered
R

4

14

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 [email protected]
    - git config --global user.email "[email protected]"
    - 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?

Ramey answered 7/2, 2020 at 8:25 Comment(1)
Check that your Gitlab project has an activated runner that follows the ios tag.Bouldon
B
10

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.

Bouldon answered 7/2, 2020 at 9:30 Comment(4)
now I see that one of the available runners are grey (instead of green). Grey is the one with ios tag. Why did it happened and how to make it work again?Ramey
@Ramey That means the runner is offline. As I mentioned, check with gitlab-runner verify that the runner is indeed "alive". If it isn't, try doing gitlab-runner restart.Bouldon
Ok, now I see it is online and should work.. But in gitlab it shows pending and shows job is stuck. Check runners. Have no idea why it's so...Ramey
@Ramey Did you "Retry" the job or re-trigger the pipeline? 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.Bouldon
V
6

There's another instance where you might see this message, which isn't obvious on the first sight.

If your runner is set to only run jobs from protected branches and you "protected" the branch after the pipeline was created then retrying the stuck job won't work. You need to trigger a new pipeline.

Vietnamese answered 3/12, 2021 at 18:52 Comment(0)
C
2

Go to the project's Settings > CI/CD and expand the Runners section. Find the runner you want to pick untagged jobs and make sure it's enabled. Click the pencil button. Check the Run untagged jobs option. Click the Save changes button for the changes to take effect.

This will solve the problem

Control answered 18/10, 2022 at 8:15 Comment(0)
S
0

Another reason might be that the branch that triggers the job is not protected, but the runner is.

You can protect runners so they don’t reveal sensitive information. When a runner is protected, the runner picks jobs created on protected branches or protected tags only, and ignores other jobs.

Source

Sielen answered 25/8, 2022 at 12:12 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.