How to access GitLab CI/CD secure file from Python script?

Hi, I’ve successfully added GitLab Secure File into my YAML configuration (and confirmed with ls-lah showing the file in the output, however I’m having trouble with accessing the secure file from within my Python script. My secure file lives within a folder named test-folder so in my Python script, I tried the following:

with open('test-folder/file_name', "rb") as key:

However in my pipeline output it’s showing this error:

FileNotFoundError: [Errno 2] No such file or directory: 'test-folder/file_name'

Any ideas on how I can access my secure file? Any help is appreciated!

GitLab CI/CD python cicd secure

Can you show the ls -lah output from the CI/CD job log? I’m curious about file permissions being an issue here.

Hey @j0wa, I was recently experiencing a similar issue. What I found is that the download-secure-files tool seems like it is unable to honor the SECURE_FILES_DOWNLOAD_PATH variable. Either that, or I was doing something wrong which is very possible. But to solve my issue, instead of specifying that variable, I let the download-secure-files tool download to its default location .secure_files and moved the files from that location to where I needed them.