In GitLab CI/CD, managing how and when artifacts are downloaded is essential for optimizing pipeline speed and maintaining security. By default, every job in a later stage downloads all artifacts from previous stages, which can lead to bloated job execution times and unnecessary exposure of sensitive build data.
The most common way to prevent a job from downloading any artifacts is to use an empty dependencies array. This tells the GitLab Runner to skip the artifact download step entirely for that specific job. gitlab ci prevent download artifacts
If you want to prevent users from downloading artifacts through the GitLab UI or API while still allowing the pipeline to use them, you can use the access keyword (available in newer GitLab versions). : Completely prevents any user download. In GitLab CI/CD, managing how and when artifacts
: Restricts downloads to users with Developer access or higher. This tells the GitLab Runner to skip the
If you are using a Directed Acyclic Graph (DAG) via the needs keyword, jobs no longer download all previous artifacts by default. Instead, they only download artifacts from the jobs listed in needs . To completely prevent downloads while still maintaining execution order, set artifacts: false .
test_job: stage: test script: - echo "Running tests without previous build artifacts" dependencies: [] Use code with caution. 2. Using the needs Keyword (DAG)
Sometimes the best way to prevent a download is to avoid including the file in the artifact archive at all. You can use the exclude keyword to filter out specific files or directories that shouldn't be passed along. Create job artifacts - GitLab Docs