Skip to main content

Installing tools during a build

Abstract

If you need a tool that isn't preinstalled on the build machines and you can’t find a Step for it, you can always install and use them with scripts or Script Steps.

If you need a tool that isn't preinstalled on the build machines and you can’t find a Step for it, you can always install and use them with scripts or Script Steps. Add a Script step to your Workflow, and either write your script there, or run a script from your repository. Passwordless sudo is enabled in all of our build virtual machines, so you can freely use sudo if you need it.

Once you have a working script, you can also transform it into a Step and optionally share it with others (through our StepLib). Read more: Developing a new Step

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

  3. On the Workflows & Pipelines page, find the Workflow you need.

    workflow-and-pipelines.png
  4. Open the Workflow Editor.

  5. Click the + sign to insert a Step at that position from our Step Library.

  6. In the Search steps bar, search for “script” and click on the Script Step . This will add the Step to your Workflow.

  7. Click the Step in your Workflow.

  8. Insert your script into the Script content input field.

    Running a script from your repository

    If you want to run a script from your repository, you can run it from this Script Step. Paths are relative to your repository’s root. For example, if you have a Bash script at path/to/script.sh you can add it to the Script content input field and run it with the following command:

    #!/bin/bash
    set -ex
    bash ./path/to/script.sh

    You can run non-Bash scripts too, for example, a Ruby script:

    #!/bin/bash
    set -ex
    ruby ./path/to/script.rb
Example 1. Installing cmake on macOS

Install cmake with a Script Step on macOS with the following brew command:

#!/bin/bash
set -ex
brew install cmake

Brew install

You can also use the Brew install Step to install cmake and many other tools.


Example 2. Installing cmake on Linux

Install cmake with a Script Step on Linux with the following apt-get command:

#!/bin/bash
set -ex
sudo apt-get install -y cmake

Use the -y flag for apt-get

If you don’t add the -y (yes) flag to the apt-get command, apt-get will present a prompt which you have to accept or deny manually. This is not a problem on your own Linux machine but in a CI environment you can’t provide manual input for apt-get. To prevent this issue, and to auto accept the prompt, just use the -y flag, as shown in the example.

Run npm command

You can also use the Run npm command Step to install cmake and many other tools.


Example 3. Installing iOS 13 runtime on Xcode 14 stacks

Install iOS 13 runtime on Xcode 14 stacks with a Script Step.

#!/bin/bash
set -ex
sudo xcodes runtimes install "iOS 13.0"

Available simulator runtimes on macOS stacks

You can install other runtimes using a similar syntax, but keep in mind, some runtimes are already preinstalled on our stacks. If you are interested in the list of preinstalled tools, such as simulator runtimes on our stacks, you can find every available stack’s System Report on GitHub.


Installing tools by declaring deps in the bitrise.yml file

Instead of installing a dependency or tool using a dependency installer Step or Script Step, you can also use the deps option of the bitrise.yml. If you declare deps for a specific Step, the Bitrise CLI will check if that tool is installed, and will install it for you, if required.

If the selected tool or dependency is already available, the Bitrise CLI will not install it.

  1. Open your app on Bitrise.

  2. Click the Workflows button on the main page.

    opening-workflow-editor.png
  3. On the Workflows & Pipelines pages, you can:

    • Click the Edit bitrise.yml button to get to the bitrise.yml tab of the Workflow Editor.

    • Click the edit-webhook.svg button next to the name of any Workflow to open it in the Workflow Editor.

  4. Go to the bitrise.yml tab.

  5. Find the Step you need: you will declare the dependencies for that Step.

  6. Add deps below the Step title:

    workflows:
      test:
        steps:
        - script:
            deps:
  7. Declare the package manager name and the package name.

    workflows:
      test:
        steps:
        - script:
            deps:
              brew:
              - name: cmake
              apt_get:
              - name: cmake

Declaring the binary name

If you want to declare a dependency which might be available from another source (not through the package manager), then you might also want to declare the related binary name. If the package does not match the binary name, you can declare it with bin_name. An example is AWS CLI, where the package name in both package managers is awscli, but the binary itself is aws.

workflows:
  test:
    steps:
    - script:
        deps:
          brew:
          - name: awscli
            bin_name: aws