I am new to Jenkins & Powershell, I'm trying to execute my Python script as a Post Build Action step through an already existing Jenkins job.
I am using PowerShell in Jenkins Build Step powershell 'copy "${ Mylocalpath\JenkinsPythonscript.py}" ${Workspace}'
Then in the Post Build Action Step, I gave, execfile(JenkinsPythonscript.py)
When I execute the job, I get the following error
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
What I am doing wrong? Can someone help? I referred to different answers under the same topic, but not to locate the error?
You can use copy
command of windows. You need to replace \
with \\
when accessing paths in windows :
Workspace can be accessed using %WORKSPACE%
copy /Y <Source> <Destination>
copy /Y <SourcePATH> %WORKSPACE%\\
copy /Y C:\\Users\\somuj\\PycharmProjects\\TestProject\\JenkinsPythonscript.py %WORKSPACE%\\