Skip to content

Build Artifact Upload Failed — Disk Space Fix

DodaTech Updated 2026-06-24 3 min read

In this tutorial, you'll learn about Build Artifact Upload Failed. We cover key concepts, practical examples, and best practices to help you understand and apply this topic effectively.

Your CI pipeline fails with Error uploading artifact: No space left on device — the runner's disk is full. CI caches, old builds, and Docker images accumulate until there's no room for new artifacts.

The Problem

Uploading artifact...
Error: No space left on device

The CI runner (GitHub Actions, GitLab, Jenkins) ran out of disk space because previous builds left cached data, Docker images, and old artifacts on the disk.

Step-by-Step Fix

1. Clean Docker resources

# Remove all stopped containers
docker container prune -f

# Remove unused images
docker image prune -a -f

# Remove unused volumes
docker volume prune -f

# Remove everything unused
docker system prune -a --volumes -f

2. Clean CI workspace

# Jenkins
rm -rf /var/lib/jenkins/workspace/*

# GitLab Runner
rm -rf /var/lib/gitlab-runner/builds/*

# GitHub Actions
rm -rf /home/runner/work/*

# CircleCI
rm -rf ~/project/*

3. Reduce artifact retention in pipeline config

# GitHub Actions
- uses: actions/upload-artifact@v4
  with:
    name: build-output
    path: dist/
    retention-days: 7
# GitLab CI
artifacts:
  paths:
    - dist/
  expire_in: 1 week

4. Add cleanup steps to CI pipelines

# GitHub Actions
steps:
  - name: Cleanup disk space
    run: |
      sudo rm -rf /usr/share/dotnet
      sudo rm -rf /opt/ghc
      sudo rm -rf /usr/local/share/boost
      df -h

5. Monitor disk space with alerts

#!/bin/bash
# cron job to alert on low disk space
THRESHOLD=80
USAGE=$(df / | tail -1 | awk '{print $5}' | sed 's/%//')
if [ "$USAGE" -gt "$THRESHOLD" ]; then
    echo "Warning: Disk usage at ${USAGE}%"
fi

Expected output:

Before cleanup: /dev/sda1   50G   48G   2G   96% /
After cleanup:  /dev/sda1   50G   20G   30G  40% /
✓ Artifact uploaded successfully

Prevention Tips

  • Set artifact retention days to 7-30 days, not forever
  • Add docker system prune -f to nightly Cron Jobs
  • Use ephemeral CI runners (Kubernetes, auto-scaling)
  • Monitor disk usage with alerts at 80% threshold
  • Use external artifact storage (S3, GCS) instead of runner disk

Common Mistakes with upload failed

  1. Non-exhaustive pattern matches that compile with warnings then crash at runtime
  2. Misunderstanding that String is [Char] with poor performance for large text operations
  3. Using foldl instead of foldl' causing stack overflow on large lists

These mistakes appear frequently in real-world ARTIFACT code. DodaTech's contributors have identified these patterns through analysis of open-source projects and production systems.

Practice Exercise

Write a pure function that safely divides two integers using Maybe, then test it with edge cases like division by zero and negative numbers.

This exercise reinforces the concepts covered in this guide. Try implementing it before checking online solutions.

FAQ

### Which CI provider has the smallest default disk space?

GitHub Actions has 14GB for Ubuntu runners, 10GB for Windows. GitLab SaaS runners have about 25GB. CircleCI has 100GB for performance plans. Self-hosted runners depend on your hardware. Check your provider's documentation for exact limits.

How do I clean disk space in GitHub Actions before the artifact upload step?

GitHub provides a cleanup action: jlumbroso/free-disk-space@main removes dotnet, Android SDK, and other pre-installed tools. Use it before the build step if you need more disk space. Note that the cleanup takes 2-3 minutes.

Can I store artifacts outside the CI runner (S3, GCS)?

Yes. Use dedicated upload steps that push to S3, GCS, or Azure Blob Storage. Most CI providers also have built-in artifact storage that doesn't count against runner disk. Configure artifact settings to use external storage.

Built by the developers of DodaTech

Doda Browser, DodaZIP & Durga Antivirus Pro