Ive started getting the "detected dubious ownership in repository" Error when I have a pipeline push commits to my repo. The push is successful, but subsequent pipelines on the commit fail
/usr/bin/git exited with 128: fatal: detected dubious ownership in repository
at '/opt/atlassian/pipelines/agent/build'
To add an exception for this directory, call:
git config --global --add safe.directory
/opt/atlassian/pipelines/agent/build
Hi Nabil,
Does this error show in the output of a command that is running during the build?
This error shows by Git due to a change introduced in Git 2.35.2 (and newer) to prevent a user from executing git commands in a repository owned by a different user.
The user who owns the files in the build container is root by default. If you are running Git commands with a different user, this error will show mentioning that the directory is owned by another user.
You can add an exception for the clone directory by adding the following command in the script of your bitbucket-pipelines.yml file prior to the command that gives the error:
git config --global --add safe.directory /opt/atlassian/pipelines/agent/build
You can find more details on this knowledge base article we have:
Please feel free to let me know if this works for you and if you need further assistance.
Kind regards,
Theodora
It would be nice if the Bitbucket Pipelines Runner would do this on its own after cloning in "Build setup".
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Tristan,
During the build setup, the repo is cloned in a a different Docker container than the build container, and then the clone directory is mounted in the build container. Executing this command during build setup would have no effect on this error, as the config would apply to the clone container and not the build container. The command mentioned in my previous reply needs to be executed in the build container by adding it to the yml file.
This feature request https://jira.atlassian.com/browse/BCLOUD-23217 would solve the issue if implemented, as it would allow you to specify the owner of the clone dir to be the same as the user that Pipelines runs as.
Kind regards,
Theodora
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.