Search code examples
bitrise

Bitrise CLI clone a project


I am trying to setup BITRISE CLI, I am unable to download the project source code using BITRISE CLI. How do i clone my project hosted in git hub using bitrise cli in my local machine?


Solution

  • The Bitrise CLI is designed to be use in two different ways:

    • Use it in a CI environment where retrieving the code should be part of the process.
    • Use it on your local Mac/PC where you already have the code so no need to retrieve it.

    If you install the CLI and just bitrise run on your Mac/PC then it'll run in the second mode, which expects you already have your code there, so the related steps will be skipped.

    In a CI environment, or if you want to force the "CI mode" on your own Mac/PC you should set the CI environment variable to true before you'd run the bitrise cli. The CLI also has a command line flag option which can be used to activate this mode:

    $ bitrise --help
    
    NAME: bitrise - Bitrise Automations Workflow Runner
    
    USAGE: bitrise [OPTIONS] COMMAND/PLUGIN [arg...]
    
    VERSION: 1.16.1
    
    GLOBAL OPTIONS:
      --loglevel value, -l value  Log level (options: debug, info, warn, error, fatal, panic). [$LOGLEVEL]
      --debug                     If true it enabled DEBUG mode. If no separate Log Level is specified this will also set the loglevel to debug. [$DEBUG]
      --ci                        If true it indicates that we're used by another tool so don't require any user input! [$CI]
      --pr                        If true bitrise runs in pull request mode.
      --help, -h                  show help
      --version, -v               print the version
    ...
    

    As you can see the --ci flag can be used to enable this mode (e.g. bitrise --ci run ...), as well as the CI environment variable.

    When you run the Bitrise CLI is CI mode it'll simply set the .IsCI run_if condition to true, otherwise in non CI mode it's false. What this means is, there are certain Steps which leverage this flag, and are marked by default to only run in CI mode - see for example the Git Clone step's definition: https://github.com/bitrise-io/steps-git-clone/blob/13fc7d29662bc68aaead618a72d499fb0f031d6c/step.yml#L18

    You can of course overwrite this run_if in your own bitrise.yml, it's just the default config.

    So another way to force a step to run in any environment is you marking it in your bitrise.yml with run_if: true.

    Related links: