Nothing Special   »   [go: up one dir, main page]

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adds support for defining the PowerShell version to be used #15

Closed

Conversation

M1kep
Copy link
@M1kep M1kep commented Apr 28, 2020

This adds the ability to force the plugin to use Windows PowerShell or PowerShell core. The default value is the current method of determining which version to use.

Reference: https://issues.jenkins-ci.org/browse/JENKINS-52421

@Herr-Sepp
Copy link

Thank you for your work. I was waiting for this.

But i found out that it is not posssible to output UTF-8 sign with Powershell Core and this PR.

Powershell-Plugin with your PR and pwsh 7.0:
Write-Host "UTF-8 Sign: ✅" >> UTF-8 Sign: �o.

Bash-Buildstep with pswh 7.0:
pwsh -command "Write-Host UTF-8 Sign: ✅" >> UTF-8 Sign: ✅

I only have a Windows Jenkins environment and can't test if it's because of your changes.
Maybe you can find out why the plugin does not support UTF-8, because Powershell Core does.

@Herr-Sepp
Copy link

And the Plugin crashes on Jobs that were created with a old version of this Plugin because "powerShellVersionPreference" was never set :

Running as SYSTEM
Baue in Arbeitsbereich C:\Program Files (x86)\Jenkins\workspace\Hyper-V-Tests
ERROR: Build step failed with exception
java.lang.NullPointerException
	at hudson.plugins.powershell.PowerShell.buildCommandLine(PowerShell.java:53)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:109)
	at hudson.tasks.CommandInterpreter.perform(CommandInterpreter.java:66)
	at hudson.tasks.BuildStepMonitor$1.perform(BuildStepMonitor.java:20)
	at hudson.model.AbstractBuild$AbstractBuildExecution.perform(AbstractBuild.java:741)
	at hudson.model.Build$BuildExecution.build(Build.java:206)
	at hudson.model.Build$BuildExecution.doRun(Build.java:163)
	at hudson.model.AbstractBuild$AbstractBuildExecution.run(AbstractBuild.java:504)
	at hudson.model.Run.execute(Run.java:1856)
	at hudson.model.FreeStyleBuild.run(FreeStyleBuild.java:43)
	at hudson.model.ResourceController.execute(ResourceController.java:97)
	at hudson.model.Executor.run(Executor.java:428)
Build step 'PowerShell' marked build as failure
Finished: FAILURE

If the job is saved after updating the plugin it works again

@M1kep
Copy link
Author
M1kep commented May 14, 2020

Ah good catch on the UTF-8 @Herr-Sepp I'll dig into that one. The old jobs failing is one of the biggest blockers at the moment for the WIP flag. I'll dig back into this this evening

@M1kep
Copy link
Author
M1kep commented May 14, 2020

So, I've confirmed that the UTF-8 Icon issue is present with the current PowerShell Plugin version on windows builds.

MacOS PR Version: Works
Windows Current Version: "UTF-8 ?"

Fixes issues with builds that have not been edited since updating the plugin
@M1kep
Copy link
Author
M1kep commented May 14, 2020

@Herr-Sepp Issue with existing pre-existing jobs failing should be resolved. Will be running on my instance for a bit prior to removing WIP but I believe it's usable now

Also in regard to UTF-8, I'm not too positive what the root cause of that is. I may dig into it one of these nights when I get some time. I'll most likely review how the shell integration is pulling the values. I'm seeing issues with the UTF-8 when using a Bash build step so it may be a deeper issue as I see quite a few results when googling UTF-8 Jenkins Windows

@Herr-Sepp
Copy link

Thanks!
I can confirme that now old jobs work.

To get UTF-8 support on Windows you must start jenkins with
-Dfile.encoding=UTF8
because of the old jre that is used

Jenkins.xml Line 41
From
<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>
to

<arguments>-Xrs -Xmx256m -Dhudson.lifecycle=hudson.lifecycle.WindowsServiceLifecycle -Dfile.encoding=UTF8 -jar "%BASE%\jenkins.war" --httpPort=8080 --webroot="%BASE%\war"</arguments>

after a restart other plugins like bash output UTF-8 correctly

@ev-psaad
Copy link

Any updates on this? I would love to be able to use PS Core on my Windows Jenkins host, but this plugin defaults to PowerShell.exe and not pwsh.exe.

@M1kep M1kep changed the title WIP: Adds support for defining the PowerShell version to be used Adds support for defining the PowerShell version to be used Sep 4, 2020
@M1kep
Copy link
Author
M1kep commented Sep 4, 2020

Removed WIP flag. I've been running this on my instance for a bit now, and have not run into any issues. Open to suggestions or changes as needed.

@chrisalbrecht Anything you would like to see changed prior to considering to merge?

@M1kep
Copy link
Author
M1kep commented Sep 8, 2020

Adding the other two maintainers as I'm unsure who manages Pull Requests for this repository.

@damienfinck @froque

@froque
Copy link
Member
froque commented Sep 15, 2020

This seems to be the wrong approach for me.

I think that using ToolInstallation is the proper way to define where to get the tool path for a given slave in Jenkins.

Here is a list of examples of ToolInstallation: https://www.jenkins.io/doc/developer/extensions/jenkins-core/#toolinstallation

A simple plugin that uses this is vstestrunner-plugin, where we can get some inspiration.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants