0

I am running docker on a Debian 9 machine, and a Jenkins container in it. I installed the PowerShell plugin in Jenkins and I am trying to run a PowerShell script, but I get a message saying that it can't find Powershell.exe (duh!)

I don't want to run docker on Windows. Is there a way to make PowerShell work on a Jenkins container running on a Linux machine?

Caused:

java.io.IOException: Cannot run program "powershell.exe" (in directory "/var/jenkins_home/workspace/Revert Plugin"): error=2, No such file or directory

  • Powershell v6 is cross platform and can be installed on Linux as far as I know. Having said that, it does not have anywhere near the number of comdlets that powershell v5 does. So if you expect to take a powershell script that was written to run on windows then run that script on linux, the script will have to be very simplistic or you will have to be very lucky. – EBGreen May 14 '18 at 16:55
  • This is the error. Caused: java.io.IOException: Cannot run program "powershell.exe" (in directory "/var/jenkins_home/workspace/Revert Plugin"): error=2, No such file or directory – aristosv May 14 '18 at 16:58
  • So it sounds like you need to get powershell installed then make sure jenkins knows where to find it. Also, always add new information by editing your question. – EBGreen May 14 '18 at 17:00
  • This was really not helpful. – aristosv May 14 '18 at 17:07
  • I don't know what else to tell you. That is what the error indicates. I suppose I could paste the link for the document on how to install powershell on linux but that was a simple google search that I thought was obvious. – EBGreen May 14 '18 at 17:14
0

According to the documentation, the Jenkins Powershell plugin provides integration with "Windows PowerShell" Which is not the same as the cross platform Powershell (Core). It is very likely that this is not the setup you are looking for. You may be able to rewrite the powershell script to allow it to run on linux, but you would also likely have to install powershell (core) on the windows resources to be managed, and possibly also install OpenSSH on the windows resources.

| improve this answer | |
0

Another idea: after installing powershell core, at the cli you should now have pwsh available. Create an alias: powershell pointing at pwsh.

Something like this should suffice: echo "alias powershell=pwsh" >> /Users/`(whoami)`/.profile . /Users/`(whoami)`/.profile

verify using:

powershell

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.