When running Spring Application Advisor commands (specifically advisor mapping or cf repo onboard-app), the execution fails with the following error in the logs or console:
Failed to fetch versions from repository: file://?/.m2/repository
Spring Application Advisor
The Spring Application Advisor is a Java-based tool that relies on the user.home Java system property to locate the local Maven repository (.m2). If the $HOME environment variable is not defined or exported in the shell where the tool is running, Java defaults to a ? for the user's home directory, resulting in an invalid file path.
To get the advisor mapping command working, you need to ensure the environment explicitly knows the location of the jenkins home directory. You can use any of the following approaches:
1. Export $HOME Explicitly In your current terminal session, simply define the $HOME environment variable right before executing the advisor command.
export HOME=/path/to/userhome # Replace with the actual home path
advisor mapping create -c ...2. Use a Login Shell Exit your current terminal session and switch back into it using the - flag. This spawns a full login shell, which automatically initializes all necessary environment variables, including $HOME.
sudo su - <your-user-name>
3. Force the Java System Property You can forcefully inject the user.home property. Modern JVMs automatically pick up properties passed via JAVA_TOOL_OPTIONS:
export JAVA_TOOL_OPTIONS="-Duser.home=/path/to/userhome"
advisor mapping create -c ...
Once the CLI can resolve the path, it will successfully locate your ~/.m2/settings.xml file and populate your .m2/repository as expected.