2018-03-15

How to let Jenkins to Run Powershell in x64 mode

Automation tool Jenkins is running as x86 service which means that its running all of the scripts under x32 mode - and that makes troubles to some cmdlets (extensions which are available only in x64).

I needed to run IIS stuff using "Import-Module WebAdministration" calling in .ps1 script, but by default is was throwing error.

So what I did, I spent long time by trying to found solution. After coupe of trials, I found that you need to use <SYSNATIVE> path to Powershell to be running on same as system architecture.

so instead of powershell.exe -File $env:WORKSPACE\x86-x64.ps1
I let to run  C:\Windows\sysnative\windowspowershell\v1.0\powershell.exe -File $env:WORKSPACE\x86-x64.ps1

What is not working

First at all nothing with Java, JRE, JDK etc. because it's not even installed on server - Jenkins is using encapsulated private JRE inside and it's not allowed to touch it. Don't put messy Java to your server when is not needed, you significantly decrease risk of security issue.

Secondly, you need to use path with sysnative, if you use standard path then is not working as well - see screenshots.








Thirdly, I tried to use relaunch powershell script to x64 (using $myInvocation.InvocationName) and it was changing running architecture, but since I am using parameters it wasn't working as well, because parameters get lost

Anyway

Where to found paths to all version of Powershell? Use system links at %APPDATA%\Microsoft\Windows\Start Menu\Programs\Windows PowerShell\

Žádné komentáře :

Okomentovat

Dotaz, připomínka, oprava?
(pokud máte problém s vložením příspěvku, vyzkoušejte to v prohlížeči Chrome)