We are developing a auto-deployment script that needs to run in Hudson's "Execute Shell" step.Currently the script reads param
1. GroupId:ArctifactId:Version:Packaging(The project is Mavenized) 2. Servername:VahRoot:TcInstanceI need to read G:A:V:P param from pom.xml which is specified in the Hudson Job configuration. Although Hudson provide WORKSPACE env-var it becomes difficult to search for pom.xml in the workspace , considering there might be scenario where the current executing pom name is pom.xyz.xml.
#!/bin/bash
usage()
{
echo "Usage: $0 -s-r-g-a-v-p-i";
exit 1;
}
if [ $# -lt 14 ] ; then
usage;
fi
# ":" decides which options require an argument
while getopts s开发者_开发百科:r:g:a:v:p:i: opt
do
case "$opt" in
s) echo "hello $OPTARG";
serverName=$OPTARG;;
r) echo "hello $OPTARG";
vahroot=$OPTARG;;
g) echo "hello $OPTARG";
groupid=$OPTARG;;
a) echo "hello $OPTARG";
artifactid=$OPTARG;;
v) echo "hello $OPTARG";
version=$OPTARG;;
p)echo "hello $OPTARG";
packagetype=$OPTARG;;
i)echo "hello $OPTARG";
tcinstance=$OPTARG;;
\?) usage;;
esac
done
cd $vahroot
echo "Now in $vahroot"
source $vahroot/admin/env/vahenv.sh
tcmgr.sh restart -t all
echo "$?"
if [ $? -ne 0 ]
then
echo "Exception occured"
exit 1;
fi
version_chk="SNAPSHOT"
if [[ $version =~ $version_chk ]]
then
echo "groupid is $groupid artifactid $artifactid version $version packagetype $packagetype tcinstance $tcinstance"
tcmgr.sh deploy -w nexus://snapshots:$groupid:$artifactid:$version:$packagetype -i $tcinstance
exit 0;
else
echo "groupid is $groupid artifactid $artifactid version $version packagetype $packagetype tcinstance $tcinstance"
tcmgr.sh deploy -w nexus://releases:$groupid:$artifactid:$version:$packagetype -i $tcinstance
exit 0;
fi
I need help with read the hudson config to give me the pom location specified in the job so that I need not ask the user to enter the G:A:V:P param.
There are several deployment plugins available for hudson (jenkins) that can do the job for you. In case this is not an option for you: you can pass the hudson environment variable WORKSPACE
to your script and relative to that it should be easy to find the pom.xml in the workspace.
精彩评论