我编写了一个脚本,它将项目名称作为参数,并通过迭代参数在它们之上运行一个 maven 构建。
#!/bin/bash -xv
name=`date +%Y:%m:%d-%T`
start_time=`date +%s`
filename="log-"$name
un=`whoami`
cd "/home/"$un"/projects/buildlogs/"
`touch $filename`
filepath="/home/"$un"/projects/buildlogs/"$filename
echo "Logging to "$filepath"."
echo $@
for var in $@
do
path="/home/"$un"/projects/"$var
echo $path
cd $path
pwd
echo "Building "$var"."
mvn clean install -Dmaven.test.skip=true -o &>> $filepath
mvn eclipse:clean eclipse:eclipse -o &>> $filepath
done
end_time=date +%s
echo "Build Successful!"
echo "Execution Time: "$(($(($end_time-$start_time))/60))" mins."
这里的问题是脚本在实际构建过程开始之前退出,并且构建过程的输出显示在终端本身上,尽管我为输出设置了重定向。请告诉我我在这里做错了什么。