Build Artifact Upload Failed — Disk Space Fix
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 -fto 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
- Non-exhaustive pattern matches that compile with warnings then crash at runtime
- Misunderstanding that
Stringis[Char]with poor performance for large text operations - Using
foldlinstead offoldl'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
Built by the developers of DodaTech
Doda Browser, DodaZIP & Durga Antivirus Pro