Prev Next

Maven / GitLab CI Basics Interview Questions

What are common reasons a GitLab CI pipeline fails and how do you troubleshoot them?

When a pipeline fails, GitLab provides job logs, exit codes, and visual indicators to help diagnose the issue. A systematic approach to troubleshooting resolves most failures quickly.

Common failure causes and fixes
FailureLikely causeFix
Job stuck in 'pending'No runner available with matching tagsCheck runner availability; verify job tags match a runner
'script: command not found'Tool not installed in the Docker imageChange image to one that includes the tool, or install it in before_script
TimeoutJob exceeds project or job timeoutIncrease timeout or optimise the slow step
Artifact not foundDependency job failed or wrong pathCheck dependency job passed; verify artifact path
Permission denied (push)CI_JOB_TOKEN lacks write accessEnable token access in Settings > CI/CD > Token access
Cache not workingCache key mismatch or runner has no cache storageCheck cache key; verify runner has cache storage configured
YAML syntax errorInvalid .gitlab-ci.ymlUse CI Lint tool to validate before committing
# Debugging tips:

# 1. Check the full job log - error is usually at the bottom
# Build > Pipelines > Click the failed job > View log

# 2. Add debug output to the script:
job-debug:
  script:
    - env                        # print all environment variables
    - ls -la                     # show workspace contents
    - which node && node -v      # verify tools are installed
    - cat /etc/os-release        # check OS in the Docker image

# 3. Enable CI/CD debug logging:
variables:
  CI_DEBUG_TRACE: "true"         # very verbose - shows all shell commands

# 4. Re-run a single failed job:
# Click the failed job > Retry
# Or retry from the pipeline view

# 5. Use CI Lint to validate YAML before pushing:
# Build > Pipelines > CI Lint

Most common beginner mistake: setting GIT_STRATEGY: none in a job that actually needs repository code, or forgetting that artifacts from a failed job are not available by default (add artifacts: when: on_failure to capture debug files from failing builds).

A GitLab CI job is stuck in 'pending' for a long time. What is the most likely cause?
What does setting CI_DEBUG_TRACE: 'true' do in a GitLab CI job?

Invest now in Acorns!!! 🚀 Join Acorns and get your $5 bonus!
Acorns Logo

Invest now in Acorns!!! 🚀
Join Acorns and get your $5 bonus!

Earn passively and while sleeping

Acorns is a micro-investing app that automatically invests your "spare change" from daily purchases into diversified, expert-built portfolios of ETFs. It is designed for beginners, allowing you to start investing with as little as $5. The service automates saving and investing. Disclosure: I may receive a referral bonus.

Robinhood Logo

Invest now!!! Get Free equity stock (US, UK only)!

Use Robinhood app to invest in stocks. It is safe and secure. Use the Referral link to claim your free stock when you sign up!.

The Robinhood app makes it easy to trade stocks, crypto and more.


Webull Logo

Webull! Receive free stock by signing up using the link: Webull signup.

More Related questions...

What is GitLab CI/CD and what problem does it solve? What is the.gitlab-ci.yml file and where must it be placed? What is a GitLab CI/CD pipeline? What are stages in GitLab CI/CD and how do you define them? What is a CI/CD job in GitLab and what are the required keywords? What is a GitLab Runner and what types are available? What is the 'script', 'before_script', and 'after_script' keywords and how do they differ? How do you use the 'image' keyword to specify a Docker environment for a job? What are GitLab CI/CD artifacts and how do you use them? What is the difference between cache and artifacts in GitLab CI? What are GitLab CI/CD variables and what types are available? What are the most important predefined CI/CD variables in GitLab? What are 'rules' in GitLab CI/CD and how do they control when jobs run? What is the difference between 'only/except' and 'rules' in GitLab CI? What is the 'needs' keyword in GitLab CI/CD and what problem does it solve? What is the 'workflow' keyword in GitLab CI and how does it control pipeline creation? What is the 'extends' keyword and how does it enable job templates? What is the 'include' keyword and how do you share CI configuration across projects? What are GitLab environments and how do you define them in CI/CD? What are manual jobs in GitLab CI/CD and how do you configure them? What is the 'allow_failure' keyword and how does it affect pipeline status? How does parallel job execution work in GitLab CI/CD? What are GitLab CI/CD scheduled pipelines and how do you set them up? What are pipeline triggers and how can a pipeline be started without a git push? What is the 'retry' keyword and how do you handle flaky tests in GitLab CI? What is the 'timeout' keyword in GitLab CI and what are the defaults? What is the GitLab Container Registry and how do you use it in CI/CD pipelines? What are 'services' in GitLab CI/CD and how do you use them? What is the 'default' keyword in GitLab CI and how does it reduce duplication? What are YAML anchors and aliases in GitLab CI and how do they reduce duplication? What is a merge request pipeline in GitLab CI and how does it differ from a branch pipeline? What is pipeline caching and how do you configure cache keys? What is the GitLab CI Lint tool and how do you validate a.gitlab-ci.yml file? What are GitLab CI/CD components and how do they differ from includes? What are parent-child pipelines in GitLab CI/CD? What is the 'resource_group' keyword and how does it prevent concurrent deployments? What are GitLab's built-in security scanning templates and how do you enable them? What is the 'GIT_STRATEGY' variable in GitLab CI and what are the options? What are protected branches and protected variables in GitLab CI? What are common reasons a GitLab CI pipeline fails and how do you troubleshoot them?
Show more question and Answers...

Testing

Comments & Discussions