Knapsack Pro

Why do I see 'HEAD' instead of a correct branch name in the user dashboard?

Knapsack Pro detects your branch name from environment variables of supported CI providers (Ruby, Cypress, Jest). Sometimes the CI provider may expose the HEAD instead of branch name (for instance for pull request merge commits).

The same can happen for CI provider not supported by default by Knapsack Pro when you use KNAPSACK_PRO_REPOSITORY_ADAPTER=git (Ruby, Cypress, Jest) to use local git installed on CI node to detect the branch name and git commit.

Knapsack Pro uses git command git -C /home/user/project_dir rev-parse --abbrev-ref HEAD to detect branch name. In most of cases it's good way to detect branch name. But if your CI provider during CI build checkouts to specific git commit then git cannot provide the name of the branch. In such scenario you would see HEAD as your branch name. It is good enough situation and Knapsack Pro will work correctly. The benefit of knowing exactly the branch name allows KnapsackPro API to better track history of test files timing changes across branches in order to better do split of test suite. The difference should be rather very small so it's not a problem that you have HEAD as branch name.

If you would like to see exact branch name instead of HEAD in your build metrics history in user dashboard then you can explicitly provide the branch name with KNAPSACK_PRO_BRANCH for each CI build.

Start using Knapsack Pro

Sign up and speed up your tests.