Run powershell command on slave - Jenkins -
i'm getting console output when running jenkins job on slave. job should create file , put in c:\foo\services.csv
.
here job powershell command:
get-service | export-csv c:\foo\service.csv
note word “bypass” in console output. cannot past it. think issue:
[anonymousjwtapi] $ powershell.exe -noninteractive -executionpolicy bypass "& 'c:\users\xxx\appdata\local\temp\hudson1582303083838020200.ps1'"
i found online error happens when running script sitting on master, on slave.
so manually created script on slave , put in c:\foo\listservices.ps1
. in jenkins (master) command gets run on slave: “c:\foo\listservices.ps1”
invoke script run directly slave.
im still getting same console output…something “bypass” seems still causing not work. csv file not being put in foo folder. bypass preventing working, , if so, solution?
and full console output:
started user anonymous building remotely on slave1 in workspace c:\jenkins\master\workspace\anonymousjwtapi > git.exe rev-parse --is-inside-work-tree # timeout=10 fetching changes remote git repository > git.exe config remote.origin.url c:\users\xxx\source\repos\anonymousjwtapi # timeout=10 fetching upstream changes c:\users\xxx\source\repos\anonymousjwtapi > git.exe --version # timeout=10 > git.exe -c core.askpass=true fetch --tags --progress c:\users\xxx\source\repos\anonymousjwtapi +refs/heads/*:refs/remotes/origin/* seen branch in repository origin/master seen 1 remote branch checking out revision a7087f81af855cc96b8763a5ec66b96c19a44a30 (origin/master) > git.exe config core.sparsecheckout # timeout=10 > git.exe checkout -f a7087f81af855cc96b8763a5ec66b96c19a44a30 > git.exe rev-list a7087f81af855cc96b8763a5ec66b96c19a44a30 # timeout=10 [anonymousjwtapi] $ powershell.exe -noninteractive -executionpolicy bypass "& 'c:\users\xxx\appdata\local\temp\hudson1582303083838020200.ps1'" finished: success
edit: file getting saved master... :p
it seems slave not intended host powershell scripts or outputs of them, not aware of.
-executionpolicy bypass
ensures script file can run regardless of execution policy in place computer or user. correct, , not cause of issue.
the problem may permissions.
the jenkins slave agent running user; either user used start it, or if it's running service, service account.
the user may not have permission write c:\foo
, can check that.
another way test write workspace directory, this:
get-service | export-csv $env:workspace\service.csv
that should work. if does, change permission on c:\foo
directory, or run slave account has permission.
here's way might able tell both user running service, , workspace directory is:
get-childitem env:\ | out-string | set-content -path $env:userprofile\env.txt
this write file called env.txt
profile of user running script, containing of environment variables (including %workspace%
). you'll have browse through each user profile see ends up, , you'll know user.
Comments
Post a Comment