fatal: detected dubious ownership in repository at '/opt/atlassian/pipelines/agent/build'

Eric Poe February 9, 2025

I am using a new custom Docker image in my pipeline and am receiving the following error in the pipeline: 

 

The repository at "/opt/atlassian/pipelines/agent/build/Symfony" does not have the correct ownership and git refuses to use it:
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
The repository at "." does not have the correct ownership and git refuses to use it:
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

The docker image needs to run as a different user instead of as "root" due to requirements for an add-in to the image. The ID of that user is 100, so I have added the "run-as-user" option to my step.

image:
name: name-of-my-image
run-as-user: 100 # found by bashing into my image and running `id`
script:
-|
...

Are there any suggestions on how to fix this, either in the docker image or in the pipeline step?

1 answer

1 accepted

1 vote
Answer accepted
Theodora Boudale
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
February 11, 2025

Hi Eric,

Git introduced a change in versions 2.35.2 and newer to prevent a user from executing Git commands in a repository owned by a different user. The repo directory is owned by the root user and any commands you run in the script will run as user 100 in your Docker container, which is why this error occurs.

You can add the following command in the script of your bitbucket-pipelines.yml file, before the Git command that shows this error, and then the error should no longer occur:

- git config --global --add safe.directory /opt/atlassian/pipelines/agent/build

Please feel free to let me know how it goes!

Kind regards,
Theodora

Eric Poe February 11, 2025

The error gave that line as a fix; I just didn't know that I could add it to my pipeline script. Thank you!

Like Theodora Boudale likes this

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
TAGS
AUG Leaders

Atlassian Community Events