Using files in your builds
To use a file in your builds, you can download it using a Step like File Downloader in your Workflow, or you can use the file's automatically generated Env Var as a Step input.
There are multiple ways to use files in your Bitrise builds.
-
Most Steps that generate files store the filepath in an output Environment Variable (Env Var). Subsequent Steps in the same Workflow can re-use that Env Var to access the file.
-
You can upload a file to the Generic File Storage and use the automatically generated Env Var as a Step input value in Steps that accept URLs as an input.
-
You can upload a file to the Generic File Storage and use one of our Steps (for example, the File Downloader Step) to download the file for the build. This works with Steps that require local file paths and as such do not support URLs directly as the input value.
Downloading a file using the File Downloader Step
Once you uploaded a file to the Generic File storage, one of the ways to access it is by using the File Downloader Step. This Step is useful when you need to use a file in a Step input that only accepts local paths as a value.
The Step downloads the file in a location you specify, and then every subsequent Step can access the file in that location.
-
Open your app on Bitrise.
-
Click the
button on the main page. -
On the Workflows & Pipelines pages, you can:
-
Click the bitrise.yml tab of the Workflow Editor.
button to get to the -
Click the
button next to the name of any Workflow to open it in the Workflow Editor.
-
-
Go to the Code Signing & Files tab and then the Generic File Storage section.
-
Find your file and copy the Environment Variable (Env Var) under its filename.
-
Go to the Workflows tab.
-
Click the
button next to the name of the Workflow.
-
Add the File Downloader Step to your Workflow.
-
In the Download source url input, paste the Env Var you copied earlier.
-
In the Download destination path input, specify the path where you want to download the file.
The path must include the filename in full, extension included, and it must be relative to the root of the repository.
Using an Env Var as the input value
You can store the filepath in an App Env Var instead of specifying it directly for the input. That way you can refer to the file through the Env Var in other Steps, you won’t have to specify the path every time.
For example, if you store the path in the
BITRISEIO_MY_FILE_LOCAL_PATH
Env Var, you can use it as the path for the input, and also use it to access the file in every subsequent Step. -
Click
in the top right corner.
Downloading a file using a custom Script Step
If you don't want to use the File Downloader Step to download and access an uploaded file in your build, you can use your own custom Script Step as well. All you need to do is to get the download URL and then download the file by specifying a full download path that exists on the build machine.
Workflow Editor
bitrise.yml
-
Open your app on Bitrise.
-
Click the
button on the main page. -
On the Workflows & Pipelines page, find the Workflow you need.
-
Click the
button next to the name of the Workflow.
-
Add a Script Step to your Workflow.
-
Find the Script content input of the Step.
-
Add a script to download the file and store the destination path in an Env Var.
Uploading the file to Bitrise
If you upload the file to Bitrise, you can use the file's download URL in your script.
In the example below, the download URL is stored in the
BITRISE_IO_MY_FILE_ID_URL
Env Var. We're using envman to store the destination path in theBITRISEIO_MY_FILE_LOCAL_PATH
Env Var. Subsequent Steps can use this Env Var to access the file.#!/bin/bash set -ex # specify local download path export file_local_path=download/path/to/my/file # download the file wget -O "$file_local_path" "$BITRISEIO_MY_FILE_ID_URL" echo "file downloaded to: $file_local_path" # OPTIONALLY: export the file's local path, to be able to use it in subsequent steps as an input value envman add --key BITRISEIO_MY_FILE_LOCAL_PATH --value "$file_local_path"
Alternatively, for example, you can set the location as an App Env Var and simply download it to that path instead of defining the path inside the Script Step.
-
Open the
bitrise.yml
file of your app. -
Add a
script
Step to your Workflow.my-workflow: steps: script: inputs: - content:
-
In the
content
input, add a script to download the file and store the destination path in an Env Var.Uploading the file to Bitrise
If you upload the file to Bitrise, you can use the file's download URL in your script.
In the example below, the download URL is stored in the
BITRISE_IO_MY_FILE_ID_URL
Env Var. We're using envman to store the destination path in theBITRISEIO_MY_FILE_LOCAL_PATH
Env Var. Subsequent Steps can use this Env Var to access the file.my-workflow: steps: - script: inputs: - content: #!/bin/bash set -ex # specify local download path export file_local_path=download/path/to/my/file # download the file wget -O "$file_local_path" "$BITRISEIO_MY_FILE_ID_URL" echo "file downloaded to: $file_local_path"
Alternatively, for example, you can set the location as an App Env Var and simply download it to that path instead of defining the path inside the Script Step.
-
Optionally, export the file's local path so you can use it in subsequent Steps in the same Workflow.
my-workflow: steps: - script: inputs: - content: #!/bin/bash set -ex # specify local download path export file_local_path=download/path/to/my/file # download the file wget -O "$file_local_path" "$BITRISEIO_MY_FILE_ID_URL" echo "file downloaded to: $file_local_path" # export the file path for subsequent steps envman add --key BITRISEIO_MY_FILE_LOCAL_PATH --value "$file_local_path"