Syncing two repos in Pipelines error "unable to auto-detect email address"

お困りですか?

アトラシアン コミュニティをご利用ください。

コミュニティに質問


プラットフォームについて: Cloud のみ - この記事は、 クラウド プラットフォームのアトラシアン製品にのみ適用されます。

要約

When trying to regularly sync the main repository to the forked repository via pipelines, the pipeline could error out with the following error: 
(info) This is applicable when the clone in the Bitbucket Pipelines is turned off, Build Setup step

Output from local docker container similar to pipelines
root@35a7d8191b2d:/opt/atlassian/bitbucketci/agent/build/a-fork# git merge parent/master

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@35a7d8191b2d.(none)')

原因

When "clone" is disabled in pipelines, the git configuration for "user.email" and "user.name" is not defined. When this happens, GIT does not know who to assign an author to the commit if it needs to generate one. 

Run this command to verify if the config is configured:

git config --list --show-origin | grep user.email
git config --list --show-origin | grep user.name


GIT has a mechanism to fall back to create its own email when user.email is not configured instead of throwing an error. As per the Git Internals Environment Variable document, it says: 


EMAIL is the fallback email address in case the user.email configuration value isn’t set. If this isn’t set, Git falls back to the system user and host names.


The EMAIL environment variable is used for the fallback email, which it constructs using the system user and hostname. As per the GIT Source Code, it creates the email in the following format: 

[(username of logged in user) + @ + hostname + . + domain name (FQDN)] 


If no FQDN is set, it will add ".(none)" as the TLD domain name, such as "root@35a7d8191b2d.(none)".
(info) FQDN - Fully Qualified Domain name

This results in the error: 

# hostname - Prints hostname configured
# hostname -A - Prints FQDN

root@35a7d8191b2d:/opt/atlassian/bitbucketci/agent/build/a-fork# hostname
35a7d8191b2d
root@35a7d8191b2d:/opt/atlassian/bitbucketci/agent/build/a-fork# hostname -A
35a7d8191b2d 
root@35a7d8191b2d:/opt/atlassian/bitbucketci/agent/build/a-fork# git merge --no-edit parent/master

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'root@35a7d8191b2d.(none)')


ソリューション

There are two ways solution this error : 

  1. Configure user.config and user.name in your git config. Typically, this is configured at the Global level, but it can be configured at the system's or local level based on the preference. 
    1. 例:
      git config --global user.email "johndoe@example.com"
      git config --global user.name "John Doe
  2. Another method is to configure an FQDN in the machine or docker container. The easiest way is to edit the host file.
    1. The example below is the automated configuration of it in a non-interactive docker container, just like how it can be done in Bitbucket Pipelines. 
    2. - hostname -A 																	# Verify that FQDN is not configured
      - hostname=$(hostname) && echo $hostname 										# Set hostname variable
      - cp /etc/hosts ./hosts.new														# Copy hostname to a new directory to update it
      - sed -i "s/$hostname/${hostname}.com $hostname/g" ./hosts.new && cat hosts.new # Update hosts file with the FQDN
      - hostname && hostname -A													 	# Verify that FQDN is configured
      - cp -f ./hosts.new /etc/hosts 													#this overwrites the "/etc/hosts" file. Ensure to have a backup of it if needed. 


If you are encountering issues following this documentation - please raise a support ticket or a community support ticket for further assistance.

説明 Syncing two repos in Pipelines error "unable to auto-detect email address"
製品Bitbucket Cloud
最終更新日: 2024 年 1 月 22 日

この内容はお役に立ちましたか?

はい
いいえ
この記事についてのフィードバックを送信する
Powered by Confluence and Scroll Viewport.