Bitbucket Pipelines: the artifact is missing in the next step
One step makes a file and lists it under artifacts. The next step fails with a line such as tar: can't open 'dist/package-4.tar.gz': No such file or directory (from a community question). Bitbucket uploads a step's artifacts after its last command and puts them back before the commands of the later steps. Look at both ends in the logs first, then go through the causes Atlassian lists (Bitbucket Pipeline issues due to Artifacts related issues and Pipeline artifacts).
Look at both ends of the copy
- In the step that makes the file, expand Build teardown in the log. Atlassian's support asked one user whether it said “Successfully uploaded artifact” or showed an error about the upload (community question).
- In the step that needs it, expand Build setup and look for the artifacts being downloaded.
- Add
ls -lR dist(your artifact's folder) after the command that should make the file, and run the pipeline again. It shows whether the file is where the pattern looks.
The causes
- The file is not where the pattern looks. The command, or the project's configuration, wrote it to another folder, or not at all. In the question above, an
exit 0left in anifblock ended the step successfully before the file was written. - The path is outside the clone directory. Artifact paths are relative to
$BITBUCKET_CLONE_DIR:dist/**works,/tmp/**does not. Write the file inside the clone directory. Paths with.or..are not supported, and a pattern that starts with*needs quotes in the YAML. - Both steps are in the same parallel set. A parallel step's artifacts are not available to the other steps of its set, only to steps after it. That was the cause in the
tarquestion above: the deploy step was in the sameparallelblock as the build. - The next step doesn't download it.
download: falseskips all artifacts. Adownload:list takes only the named artifacts it lists. An artifact withtype: scopedis never downloaded by other steps; it is for logs, reports and screenshots. - It was over 1 GB after compression. The step's Build teardown then says the artifact won't be uploaded, and the build goes on to the next step. The request to fail the build instead, BCLOUD-17145, is still “Gathering Interest”. Split a folder into several artifacts, or make the file smaller.
- It expired. Artifacts are kept for 14 days after the step that made them. A manual deployment step started after that can't be run: its Deploy button is greyed out with “Artifacts have expired”, even when the step has
download: false(BCLOUD-22653, unresolved). Its workaround is to run the whole pipeline again.
- step:
name: Build
script:
- npm run build
- ls -lR dist
artifacts:
- dist/**
- step:
name: Deploy
script:
- ./deploy.sh
"Permission denied" on a script from an artifact
Downloaded artifacts get the permissions 644 (-rw-r--r--), so a script that came as an artifact can't be run until you make it executable again (the Pipeline artifacts page):
script: - chmod +x deploy.sh - ./deploy.sh
Artifacts from a step that failed
By default a step uploads its artifacts only when it succeeds. For test reports or screenshots you want after a failure, use the structured form with capture-on: failed or capture-on: always:
artifacts:
- name: Screenshots
type: scoped
paths:
- screenshots/**
capture-on: failed
See the failed command from IntelliJ IDEA
Pipeline Inbox for Bitbucket Pipelines, a plugin by Lesstep for JetBrains IDEs 2024.1 or later, lists the pipelines of all your Bitbucket Cloud repositories in an IDE tool window, with their steps. For a failed pipeline it shows the command the step failed at and that command's last lines, so the No such file or directory line is on screen without opening the log. Each step's log opens in the IDE and can be searched, so you can find the artifact lines of Build teardown and Build setup there. When the artifacts have expired, the way out is a new run of the whole pipeline: with Pro, Run again builds the same commit once more from the IDE. The list, steps and logs are free; running, re-running and stopping pipelines are Pro (US$1.50 a month, with a 30-day trial).
Get it on JetBrains Marketplace
Atlassian, Bitbucket and Bitbucket Pipelines are trademarks of Atlassian; IntelliJ IDEA is a trademark of JetBrains s.r.o. This page is not affiliated with or endorsed by either of them.
More: The cache is not used · "Step exceeded processing limits" · "Exceeded build time limit of 120 minutes" · "No space left on device" · "No online runner available" · "We couldn't clone the repository" · Submodules not cloned · "command not found" · "unexpected system error" · Pipelines did not run after a push · "Container 'Build' exceeded memory limit." · "Container 'docker' exceeded memory limit." · The build passed before and fails now · Build setup takes too long · "You've run out of build minutes" · "Permission denied to update branch" · "You have reached your pull rate limit" (Docker Hub) · "There is an error in your bitbucket-pipelines.yml" · "This pipeline was paused" (deployments) · Bitbucket Pipelines plugins for IntelliJ IDEA, compared · 日本語