[Bug]: OpenSearch Dashboards register git hook failure due to git version
See original GitHub issueDescribe the bug
While adding a Jenkins file and attempting to run a pipeline, the build is failing.
What is happening is that the build script will yarn osd bootstrap
into the OpenSearch Dashboards repo. This will call node scripts/osd
with the arg bootstrap
this will eventually run node ./preinstall_check
which then succeeds. But will then it will iterate through all the packages attempting to bootstrap. While iterating through each package it checks the package.json file for a script osd:bootstrap
and executes that script.
However, when it gets to doing [opensearch-dashboards]
it attempts to run the [osd:bootstrap] script
, which actually is node scripts/build_ts_refs && node scripts/register_git_hook
, and fails on the register_git_hook
script.
It is failing on the register_git_hook
script because the script calls packages/osd-dev-utils/src/precommit_hook/cli.ts
and in that script there is a call to packages/osd-dev-utils/src/precommit_hook/get_git_dir.ts
. Here a git command is executed: git rev-parse --get-common-dir
. This is where the failure occurs.
Locally and other Jenkins environments, git rev-parse --git-common-dir
would return .git
in the current staging Jenkins environment. git rev-parse --git-common-dir
is not returning anything besides just --git-common-dir
. Then the buid script attempts to find OpenSearch-Dashboards/--git-common-dir/hooks/pre-commit' when it should be looking for
OpenSearch-Dashboards/.git/hooks/pre-commit’ and fails on a file not found exception.
To reproduce
Run build script on Jenkins.
Expected behavior
Even though this register git hook is pointless in our build process, it should succeed on accessing the git-common-dir
and thus allow registering git hook and successfully building.
Screenshots
n/a
Host / Environment
git version of working local environment: 2.25.1
git version of working Jenkins environment: 2.17.1
git version of NON-working Jenkins environment: 2.32.0
Additional context
Although git hooks have no place in the build process removing the register git hook from osd:bootstrap
will have significant impact on the developer experience. So I don’t recommend just removing it.
We can also create a new build script but it will require code updates and I believe the correct decision is to figure out why --git-common-dir fails in the current Jenkins environment so we can keep most of the code intact.
Relevant log output
No response
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (6 by maintainers)
Top GitHub Comments
Update: this is a git related issue.
Dashboards requires a specific versions of git otherwise it will fail. I don’t think it’s appropriate to fail hard because of git version so this should be handled in the Dashboards repo and I believe it should succeed with error messages.
@opensearch-project/admin can you transfer this to https://github.com/opensearch-project/OpenSearch-Dashboards
check bundle-workflow/Jenkinsfile for reference there. Thanks.