2

I have a bash script in which I am cloning a total of 5 repositories from a private server. I don't want the user to enter his credentials again and again, hence I prompt for them once and then reuse them.

This is my code for credentials promt

read -p "Enter Username: " username 
echo -n "Enter Password: "
read -s password

However when this piece of code is run via maven, it does not display the prompt messages such as Enter Username and does not even accept the -s silent input flag. If run without maven, this script runs fine.

The catch is that if I use the read command without any flags or string prompts, it runs fine, which makes me think that maven might not be either recognizing or accepting these flags.

Has anyone else come across this? I have tried using the interactive mode in maven as well, same results.

madhead
  • 31,729
  • 16
  • 153
  • 201
m_nazir
  • 41
  • 4

1 Answers1

1

Just don't use any interactivity inside build tools. All values should be injected, provided into the builds. It's not a build tool job to prompt user for them. In Maven you can use Java System properties or environment variables:

pom.xml

<user>${sysprop.user}</user>
<password>${env.PASSWORD}</user>

bash

export PASSWORD=s3cr3t mvn task -Dsysprop.user=root

Answering your question directly: make sure that the place where you run bash script (external process) links input and output stream of that external process and the Maven's JVM process. More info here and here

madhead
  • 31,729
  • 16
  • 153
  • 201