Jenkins - 将脚本从本地文件夹复制到工作区 - 错误“无法将参数绑定到参数 'Path',因为它为空”

Jenkins - Copy script from Local folder to Workspace - Error 'Cannot bind argument to parameter 'Path' because it is null'

我是 Jenkins 和 Powershell 的新手,我正在尝试通过现有的 Jenkins 作业将我的 Python 脚本作为 Post 构建操作步骤执行。

我在 Jenkins 构建步骤中使用 PowerShell powershell 'copy "${ Mylocalpath\JenkinsPythonscript.py}" ${Workspace}'

然后在 Post 构建操作步骤中,我给出了, 执行文件(JenkinsPythonscript.py)

当我执行作业时,出现以下错误

12:20:26 Copy-Item : Cannot bind argument to parameter 'Path' because it is null.
12:20:26 At line:1 char:6
12:20:26 + copy ${ C:\Users\somuj\PycharmProjects\TestProject\JenkinsPythonscript.py} ${Wor ...
12:20:26 +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
12:20:26     + CategoryInfo          : InvalidData: (:) [Copy-Item], ParameterBindingValidationException
12:20:26     + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.CopyItemCom 
12:20:26    mand
12:20:26  
12:20:26 Build step 'PowerShell' marked build as failure
12:20:26 [PostBuildScript] - [INFO] Executing post build scripts.
12:20:26 [gNS_Reports_Nexis_Cert1_Regression] $ cmd /c call C:\Users\devops\AppData\Local\Temp\jenkins2116124088026791482.bat

我做错了什么?有人可以帮忙吗?我在同一个话题下提到了不同的答案,但没有找到错误?

enter image description here

您可以使用 windows 的 copy 命令。访问 windows 中的路径时需要将 \ 替换为 \ :
可以使用 %WORKSPACE%

访问工作区
copy /Y <Source> <Destination>
copy /Y <SourcePATH> %WORKSPACE%\


输入命令:


copy /Y C:\Users\somuj\PycharmProjects\TestProject\JenkinsPythonscript.py %WORKSPACE%\