Bitbucket Pipelines dubious ownership error

Nabil Becker
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 11, 2022

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

1 answer

1 vote
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 15, 2022

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

Tristan Ramseyer July 4, 2024

It would be nice if the Bitbucket Pipelines Runner would do this on its own after cloning in "Build setup".

Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
July 8, 2024

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

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events