我有一个类似于这样的项目:
project
|
├───src
│ Utility.groovy
│
└───vars
pipeline.groovy
script.ps1
在
pipeline.groovy
文件中,我有一个实用对象:def util = new Utility(this)
其中一步调用util.scriptCall(arg1: "1", arg2: "2", arg3: "3")
,该函数被定义为:
this.context.powershell returnStdout: true, script: ".\\script.ps1 -Arg1 ${args.arg1} -Arg2 ${args.arg2} -Arg3 ${args.arg3} -Workspace ${this.context.env.workspace}"
根据我找到的所有资料,我应该是正确调用了它,然而我却收到了以下错误信息:
.\script.ps1 : The term '.\script.ps1' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
我已经安装了 PowerShell 插件,但是对于任何与 Jenkins 相关的东西缺乏文档并没有帮助。我已经将 script.ps1
移动到 src
文件夹中,甚至尝试为此创建了一个 scripts
文件夹,但结果仍然相同。
你有任何想法吗?为什么我的脚本调用会被解释为一个 cmdlet?
.
)中找不到该脚本。你知道运行该命令时的当前工作目录是什么吗?如果不知道,也许可以加上pwd
或ls
等命令来查看输出。也许你所在的目录是project
,那么你需要调用./src/script.ps1
(顺便说一下,PowerShell 在使用正斜杠/
时效果很好,以防你想避免一直转义反斜杠)。 - briantist/
信息!我一直以为Jenkins的工作空间是vars
目录,但我会尝试更改路径,看看能否得到任何结果。 - starscream_disco_party