situation -
I'm trying to run a simple test where i upload a file
using a command like so
await page.locator('input[type="file"]').nth(0).setInputFiles('/opt/atlassian/pipelines/agent/build/../sample-img.png');
the file /sample-img.png is stored inside the repository
issue -
locally this works fine , but when running it in the pipeline it wont be able to find the ../sample-img.png
it cant find the path to the file for some reason
i tried every variation of ./sample-img.png and adding the upper path which is tests/sample-img.png , nothing works
from what i understood its because the file is stored in a different path in the machine that is running the pipeline , but i cant find how to find it
someone suggested to use
- ls -LaR
but maybe I'm not using it correct , adding it to the pipeline step simply does nothing
can someone help which what path i need to put before the sample img? or what can i do to solve this issue?
Hi Maxim,
Welcome to the community!
As you alluded to the issue you're encountering is likely due to the difference in file paths between your local environment and the pipeline environment. When running tests in a CI/CD environment like Bitbucket Pipelines, you need to ensure that any required files are available at the expected path during the test execution.
My understanding is that you have a test file (sample-img.png) that is used during the tests executed on your pipeline. In this case, you need to make sure that the file is included in your repository in a directory tests/sample-img.png and on the branch where the build is executing. For example if your file is on the main branch but your build is executing on a branch develop where that file and folder does not exist the build will not be able to locate the file.
Here's an example bitbucket-pipelines.yml to help locate the file
image: atlassian/default-image:3
pipelines:
default:
- step:
script:
- pwd # Print working directory
- ls -LaR # Show all files in the repo
- ls -l tests/sample-img.png # Verify file exists
Hopefully this helps point you in the right direction.
- Phil
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.