帮助使用 Hudson 自动部署脚本

发布于 2024-11-02 19:55:01 字数 1620 浏览 6 评论 0原文

我们正在开发一个自动部署脚本,需要在 Hudson 的“执行 Shell”步骤中运行。当前脚本读取 param
1. GroupId:ArctifactId:Version:Packaging(该项目已Maven化)
2. Servername:VahRoot:TcInstance

我需要从 Hudson 作业配置中指定的 pom.xml 中读取 G:A:V:P 参数。尽管Hudson提供了WORKSPACE env-var,但考虑到可能存在当前执行的pom名称是pom.xyz.xml的情况,在工作空间中搜索pom.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   

我需要帮助读取 hudson 配置,以便为我提供作业中指定的 pom 位置,这样我就不需要要求用户输入 G:A:V:P 参数。

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:TcInstance

I 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

春夜浅 2024-11-09 19:55:01

有几个可用于 hudson (jenkins) 的部署插件可以为您完成这项工作。如果这不适合您:您可以将 hudson 环境变量 WORKSPACE 传递给您的脚本,相对于此,在工作区中应该很容易找到 pom.xml。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文