简体   繁体   English

如何在詹金斯中传递powershell的参数

[英]how to pass arguments of powershell in Jenkins

this is my PS script 这是我的PS脚本

Function Publish
{
Param(
    [parameter(Mandatory=$true)]
    [String]
    $RELEASEDIR,
    [parameter(Mandatory=$true)]
    [String]
    $SERVICENAME,
    [parameter(Mandatory=$true)]
    [String]
    $SERVER
    )
Get-ChildItem "$RELEASEDIR\*"
$service = Get-Service -Name $SERVICENAME -Computername $SERVER -ErrorAction SilentlyContinue
$service.Status
}

I am trying to call PS script from Jenkins server.PS script has few arguments to get passed. 我正在尝试从Jenkins服务器调用PS脚本.PS脚本几乎没有要传递的参数。 Like.. 喜欢..

PS C:\Release\RPCPS> Publish -RELEASEDIR "C:\Release\Batchfile" -SERVICENAME "AmazonSSMAgent" -SERVER "10.0.1.91" 

how to pass arguments of powershell script in Jenkins. 如何在Jenkins中传递Powershell脚本的参数。

While I use below set Up. 虽然我在下面使用设置。 My Jenkins jobs is not able to read it. 我的Jenkins工作无法阅读。 So please guide me. 所以请指导我。

在此处输入图片说明

You don't need to call powershell exe if you have installed the powershell plugin, and for your stuff to work, dot source your script 如果您已经安装了powershell插件,则无需调用powershell exe,并且为了使您的内容正常工作,请在脚本中添加源代码

. "path to script"
Publish -arg1 -arg2 -arg3

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM