I have to do several maven tests on some EARs I have.
Instead of doing them manually, I want to write a shell script which automates the process.
This is what I have:
#!/bin/bash
projects = ("MAIN_EAR", "EJB_EAR", "SIT_EAR", "ENC_EAR", "ENVIRONMENT_EAR", "PRESS_EAR")
myenvs = ("dev", "cart")
for prj in "${projects[@]}"
do
:
for myenv in "${myenvs[@]}"
do
:
mvn –am –pl "../$prj" clean package –Denvironment=$myenv
done
done
And this is the output:
back@slash-PC:~/workspace/WSP$ bash maven_tests.sh
maven_tests.sh: line 2: Syntax error near unexpected token "("
maven_tests.sh: line 2: `projects = ("MAIN_EAR", "EJB_EAR", "SIT_EAR", "ENC_EAR", "ENVIRONMENT_EAR", "PRESS_EAR")
It seems that bash doesn't like how I declared the array.
What am I missing?
If it helps: I'm on Xubuntu 14.04 x64
You can't have spaces around the =
when defining variables in bash. Also, array elements are separated with a space, not with a ,
. You'll have to use e.g.
myenvs=("dev" "cart")
There are some syntax errors esp in declaring BASH arrays. (Spaces around =
in array declaration and using commas between array elements).
Try this code:
#!/bin/bash
projects=("MAIN_EAR" "EJB_EAR" "SIT_EAR" "ENC_EAR" "ENVIRONMENT_EAR" "PRESS_EAR")
myenvs=("dev" "cart")
for prj in "${projects[@]}"; do
for myenv in "${myenvs[@]}"; do
mvn –am –pl "../$prj" clean package –Denvironment="$myenv"
done
done
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With