Maven tasks fails with error "fatal: could not read Username for https://repository-URL : No such file or directory"
Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.
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.
[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"
[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
<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
<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)
<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.