GitLab CI Job Stuck (missing tags)

The job requires specific tags that no available runners have.

Understanding GitLab CI

GitLab CI/CD is a powerful tool integrated within GitLab that automates the process of software development. It allows developers to build, test, and deploy their code efficiently. By defining a pipeline in a .gitlab-ci.yml file, developers can specify the stages and jobs that need to be executed. The tool is designed to streamline the continuous integration and continuous deployment processes, ensuring that code changes are automatically tested and deployed.

Identifying the Symptom: Job Stuck (Missing Tags)

One common issue developers encounter when using GitLab CI is a job getting stuck with the message 'Job Stuck (missing tags)'. This symptom indicates that the job is not being picked up by any runner, and it remains in the pending state indefinitely. This can be frustrating as it halts the CI/CD pipeline, delaying the development process.

Exploring the Issue: Missing Tags

The root cause of this issue is typically related to the tags assigned to the job in the .gitlab-ci.yml file. GitLab CI uses tags to match jobs with runners. If a job specifies tags that no available runners have, the job will remain stuck. This is because runners are responsible for executing jobs, and they need to have the appropriate tags to pick up specific jobs.

Understanding Tags in GitLab CI

Tags in GitLab CI are used to ensure that jobs are executed on the appropriate runners. Each runner can be assigned one or more tags, and jobs can specify which tags they require. This mechanism allows for greater control over where and how jobs are executed, especially in environments with multiple runners.

Steps to Fix the Issue

To resolve the 'Job Stuck (missing tags)' issue, follow these steps:

1. Check the Job Configuration

First, examine the .gitlab-ci.yml file to identify the tags specified for the job. Ensure that the tags are correctly defined and match the intended runners. Here is an example of how a job might be configured:

job_name:
script:
- echo "Running job"
tags:
- required_tag

2. Verify Runner Tags

Next, check the tags assigned to your runners. You can do this by navigating to the GitLab Admin Area and selecting Runners. Ensure that at least one runner has the tags required by the job. If no runners have the necessary tags, you can either modify the runner's tags or adjust the job's tag requirements.

3. Assign Tags to Runners

If you need to assign new tags to a runner, follow these steps:

  • Go to the GitLab Admin Area.
  • Select Runners from the sidebar.
  • Find the runner you want to modify and click Edit.
  • Add the required tags in the Tags field.
  • Save the changes.

4. Modify Job Tags

If changing runner tags is not feasible, consider modifying the job's tag requirements to match available runners. Update the .gitlab-ci.yml file with tags that correspond to the existing runner tags.

Additional Resources

For more information on configuring runners and tags in GitLab CI, refer to the official documentation:

By following these steps, you should be able to resolve the 'Job Stuck (missing tags)' issue and ensure your CI/CD pipeline runs smoothly.

Never debug

GitLab CI

manually again

Let Dr. Droid create custom investigation plans for your infrastructure.

Book Demo
Automate Debugging for
GitLab CI
See how Dr. Droid creates investigation plans for your infrastructure.

MORE ISSUES

Made with ❤️ in Bangalore & San Francisco 🏢

Doctor Droid