Maven tasks fails with error "fatal: could not read Username for https://repository-URL : No such file or directory"

Platform Notice: Data Center Only - This article only applies to Atlassian products on the Data Center platform.

Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Summary

Running the Maven task fails to push the code to the repository with the below error.

1 [ERROR] fatal: could not read Username for 'https://<Azure URL>': No such file or directory

Environment

The issue was observed on Bamboo 7.0.1 and Windows remote agent using Microsoft Azure repository, but the solution will be applicable for other supported versions of Bamboo. 

Diagnosis

The first step is to check the build logs to see the error : "fatal: could not read Username for '<Repository URL>': No such file or directory"

1 2 3 4 5 6 7 8 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-release-plugin:3.0.0-M1:prepare (default-cli) on project consolidated-reporting-project: Unable to commit files [ERROR] Provider message: [ERROR] The git-push command failed. [ERROR] Command output: [ERROR] Logon failed, use ctrl+c to cancel basic credential prompt. [ERROR] bash: /dev/tty: No such device or address [ERROR] error: failed to execute prompt script (exit code 1) [ERROR] fatal: could not read Username for '<Repository URL>': No such file or directory

Next step is to confirm that the maven setting.xml is using the correct username and password

1 2 3 4 5 6 7 8 9 10 11 <settings> ... <servers> <server> <id>YOUR_REPO_ID</id> <username>YOUR_USERNAME</username> <password>YOUR_PASSWORD</password> </server> </servers> ... </settings>

Now confirm that pom.xml in your Maven project is using the correct repository ID

1 <project.scm.id>my-scm-server</project.scm.id>

Last confirm that the pom.xml in your Maven project is using the correct repository (In this example I am using Github)

1 2 3 4 5 6 <scm> <connection>scm:git:https://github.com/YOUR-REPOSITORY.git</connection> <developerConnection>scm:git:https://github.com/YOUR-REPOSITORY.git</developerConnection> <url>https://github.com/YOUR-REPOSITORY</url> <tag>HEAD</tag> </scm>

Cause

There are 2 possible reasons behind this error:

Cause 1

Wrong scm.project.id: The project.scm.id in the pom.xml should match the <id> section in the settings.xml

Cause 2

Wrong username or password: The username or password in the settings.xml is incorrect

Solution

Solution 1

Make sure the scm.project.id in the pom.xml matches the <id> section in the settings.xml file

Solution 2

Make sure that you use the correct username and password in setting.xml file. 

Updated on February 25, 2025

Still need help?

The Atlassian Community is here for you.