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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.