Ruby Reference
You can configure things in two ways:
- Command-line arguments for the test runner
- Environment variables for Knapsack Pro
Unless specified otherwise, everything on this page is environment variables.
Command-line arguments
You can pass command-line arguments using the Rake argument syntax:
bundle exec rake "knapsack_pro:queue:rspec[--tag focus --profile]"
# ==
bundle exec rake rspec --tag focus --profile
Or using the knapsack_pro
binary:
knapsack_pro rspec "--tag focus --profile"
# ==
bundle exec rake rspec --tag focus --profile
KNAPSACK_PRO_BRANCH
Git branch under test.
You don't need to set it if either:
- Your CI is one of the supported CIs
- You are using
KNAPSACK_PRO_REPOSITORY_ADAPTER=git
andKNAPSACK_PRO_PROJECT_DIR
In some cases, particularly for pull request merge commits or if the CI provider checks out a specific git commit during the build process, Git might only expose HEAD
instead of the actual branch name.
KNAPSACK_PRO_BRANCH_ENCRYPTED
Enable Branch Name Encryption.
Default: false
Available: false
| true
KNAPSACK_PRO_CI_NODE_BUILD_ID
Unique ID that identifies a CI build. It must be the same for all the parallel CI nodes.
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you may generate a build ID with KNAPSACK_PRO_CI_NODE_BUILD_ID=$(openssl rand -base64 32)
and make it available to all parallel nodes.
KNAPSACK_PRO_CI_NODE_INDEX
Index of current CI node (first should be 0, second should be 1, etc.).
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you need to set it manually.
KNAPSACK_PRO_CI_NODE_RETRY_COUNT
A retry count of the current CI node in case of a single node/job retry.
There is no need to set this for the following CI providers that are supported out of the box:
- GitHub Actions
- Buildkite
For other CI providers:
If you use KNAPSACK_PRO_FIXED_QUEUE_SPLIT=true
or KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT=true
, you need to set KNAPSACK_PRO_CI_NODE_RETRY_COUNT=1
when retrying a single node to disable Fallback Mode. Otherwise, the CI node would use a different (fallback) split and run a different subset of tests when the API cannot be reached. Alternatively, disable Fallback Mode completely with KNAPSACK_PRO_FALLBACK_MODE_ENABLED=false
.
Default: 0
(or an environment variable for supported CI providers)
Available:
0
: Fallback Mode is enabled according toKNAPSACK_PRO_FALLBACK_MODE_ENABLED
> 0
: Fallback Mode is disabled and Knapsack Pro raises an error if the API cannot be reached afterKNAPSACK_PRO_MAX_REQUEST_RETRIES
tries
KNAPSACK_PRO_CI_NODE_TOTAL
Total number of parallel CI nodes.
Default: Knapsack Pro will take it from the CI environment (see supported CIs)
If your CI is not supported, you need to set it manually.
KNAPSACK_PRO_COMMIT_HASH
Hash of the commit under test.
You don't need to set it if either:
- Your CI is one of the supported CIs
- You are using
KNAPSACK_PRO_REPOSITORY_ADAPTER=git
andKNAPSACK_PRO_PROJECT_DIR
KNAPSACK_PRO_CUCUMBER_QUEUE_PREFIX
(Cucumber, Queue Mode)
Prefix to use when invoking Cucumber tests.
Default: "bundle exec"
Available:
"bundle exec"
"bundle exec spring"
or"bin/spring"
to run Cucumber faster with Spring
KNAPSACK_PRO_ENDPOINT
(Internal)
Default: https://api.knapsackpro.com
KNAPSACK_PRO_FALLBACK_MODE_ENABLED
Enable/disable Fallback Mode.
Default: true
Available:
false
: Knapsack Pro will fail the build afterKNAPSACK_PRO_MAX_REQUEST_RETRIES
true
: Knapsack Pro will switch to Fallback Mode afterKNAPSACK_PRO_MAX_REQUEST_RETRIES
KNAPSACK_PRO_FALLBACK_MODE_ERROR_EXIT_CODE
Set the exit code to use in case Knapsack Pro fails because it cannot switch to Fallback Mode.
Default: 1
KNAPSACK_PRO_FIXED_QUEUE_SPLIT
(Queue Mode)
Dynamic or fixed tests split when retrying a CI build.
Default: automagically set to the correct value for your CI provider
Available:
false
: generate a new split whenKNAPSACK_PRO_CI_NODE_BUILD_ID
changes (see what Knapsack Pro uses asnode_build_id
for your CI provider)true
: if the triplet(branch name, commit hash, number of nodes)
was already split in a previous build use the same split, otherwise generate a new split
Recommended:
true
when your CI allows retrying single CI nodes (e.g., Buildkite, GitHub Actions) or if your CI nodes are spot instances/preemptibletrue
when your CI uses the sameKNAPSACK_PRO_CI_NODE_BUILD_ID
on retries (e.g., GitHub Actions, Travis, CodeShip)false
otherwise
KNAPSACK_PRO_FIXED_TEST_SUITE_SPLIT
(Regular Mode)
Dynamic or fixed tests split when retrying a CI build.
Default: true
Available:
false
: generate a new split whenKNAPSACK_PRO_CI_NODE_BUILD_ID
changes (see what Knapsack Pro uses asnode_build_id
for your CI provider)true
: if the triplet(branch name, commit hash, number of nodes)
was already split in a previous build use the same split, otherwise generate a new split
Recommended:
true
when your CI allows retrying single CI nodes (e.g., Buildkite, GitHub Actions) or if your CI nodes are spot instances/preemptibletrue
when your CI uses the sameKNAPSACK_PRO_CI_NODE_BUILD_ID
on retries (e.g., GitHub Actions, Travis, CodeShip)false
otherwise
KNAPSACK_PRO_LOG_DIR
Default: stdout
Available: stdout
| directory
When KNAPSACK_PRO_LOG_DIR=log
, Knapsack Pro will write logs to the log
directory and append the CI node index to the name. For example:
log/knapsack_pro_node_0.log
log/knapsack_pro_node_1.log
KNAPSACK_PRO_LOG_LEVEL
Default: info
Available: debug
| info
| warn
| error
| fatal
Recommended: debug
when debugging issues, info
to know what Knapsack Pro is doing
For legacy versions of knapsack_pro
older than 7.0, please click here.
Default: debug