Stashbase

Run

Load and inject environment's secrets as environment variables and run a command

If you want to run your command and inject secrets that were loaded from the config file use the run command. Stashbase CLI will automatically search for stashbase.yaml file in the current directory.

Learn more about custom config files

There are two main ways to use ru command. You can pass the arguments directly to the command or you can use custom config file.

stashbase run [OPTIONS] [COMMAND]...

Options

Prop

Type

With custom config file

Stashbase CLI will automatically detect stashbase.yaml file in the current directory. If you use custom file name you can pass it as an --file argument to the command. You can also pass the arguments like set or print for the secrets and it will be merged with the config file.

If there are multiple entries in the config file like above, Stashbase CLI will propmpt you to select one.

Example

This is an example of using custom config file with run command.

Config file

- project: our-project
  environment: api_local
  description: Used only for database migrations
  secrets:
    expand-refs: true
    print: true
    only:
      - DATABASE_URL

- project: our-project
  environment: api_testing
  description: Run against database in test environment
  pull:
    output: .prod.env
    format: dotenv
  secrets:
    only:
      - DATABASE_HOST
      - DATABASE_PORT
      - DATABASE_PASSWORD
    set:
      - NODE_ENV: production

Command

# auto detect config file in the current directory and select
npx stashbase run -- npm run dev


# provide custom config file path
stashbase run --file my-file.yaml -- bun run dev

Without config file

You can use run command without any config file. In that case you must provide the required following required arguments directly to the command: -p, --project and -e, --environment. If you want to configure the secrets to be loaded from the environment you can manually pass options like --only and --exclude and others.

Example

stashbase run -p our-project -e api_local -- npm run dev

# pass options
stashbase run -p our-project -e api_local \
  --only DATABASE_URL \
  --exclude DATABASE_PASSWORD \
  -- npm run dev

On this page