如何将Hudson/Jenkins参数传递给Windows批处理命令 [英] How can pass Hudson/Jenkins parameters to windows batch command

查看:457
本文介绍了如何将Hudson/Jenkins参数传递给Windows批处理命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,我需要在我的Hudson Job中执行一个批处理文件,我有一个参数(Jenkis参数),我需要将此参数(如param)传递给批处理文件,我尝试了此操作:

well i need to execute a batch file in my Hudson Job, I have a parameter(Jenkis parameter) and i need to pass this value like param to batch file, i tried this:

Deploy.cmd -configuration=${DEPLOYCONFIGURATION} -source=${DeploySource}

我的Deploy.cmd配置为获取此值,但是Jenkis不分配这些值.例如,我有以下内容:

My Deploy.cmd is configurated for get this values but Jenkis doesn't assign the values.. For example, i have this:

${DEPLOYCONFIGURATION} = DEV
${DeploySource} = c:\myFolder

然后,批处理文件将使用此值

Then,the batch file take this values

%DEPLOYCONFIGURATION% = ${DEPLOYCONFIGURATION} 
%DeploySource% = ${DeploySource}

采用参数名称而不是其值

Takes the parameter name not its value

推荐答案

按如下所示执行您的批处理文件

Execute your Batch file as like the below

Deploy.cmd -configuration=%DEPLOYCONFIGURATION% -source=%DeploySource%

如果您的Jenkins服务器在unix/Linux计算机上运行,​​请使用"export"命令为Windows设置环境变量,请使用"set"命令,如下所示:

In case your Jenkins server run in unix/ Linux machine use "export" command to set environment variable for windows use "set" command like the below

对于Windows:

set DEPLOYCONFIGURATION=DEV
set DeploySource=c:\myFolder

对于Unix:

export DEPLOYCONFIGURATION = DEV
export DeploySource=c:\myFolder 

希望它可以解决您的问题.

Hope it might solve your issue.

谢谢, 玛丹

这篇关于如何将Hudson/Jenkins参数传递给Windows批处理命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆