-
Notifications
You must be signed in to change notification settings - Fork 92
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
Allow setting pwsh as powershell executable #111
Conversation
cc @slide @dwnusbaum also atm Tested both on master and this branch. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I haven't really worked much on the Powershell side really, so I don't feel comfortable giving approval actuallly, nvm, looking it over again I think I was just being overly cautious :)
cc @jglick @gabloe @jtnord perhaps you want to review my changes? |
@@ -106,8 +117,8 @@ public String getScript() { | |||
// Copy the helper script from the resources directory into the workspace | |||
c.getPowerShellHelperFile(ws).copyFrom(getClass().getResource("powershellHelper.ps1")); | |||
|
|||
if (launcher.isUnix()) { | |||
// There is no need to add a BOM with Open PowerShell | |||
if (launcher.isUnix() || "pwsh".equals(powershellBinary)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI: many launchers always say true
and lie :-( (but this is existing issue)
The binary is pwsh.exe
(and on windows is normally case insensitive - so this should allows pwsh
pwsh.exe
and all cases of that if I understand the intent here)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not have to specify pwsh.exe
, pwsh
is fine.
@jtnord this is existing logic that been working for quite awhile
see existing code
durable-task-plugin/src/main/java/org/jenkinsci/plugins/durabletask/PowershellScript.java
Lines 86 to 96 in 93b86c9
// Note: PowerShell core is now named pwsh. Workaround this issue on *nix systems by creating a symlink that maps 'powershell' to 'pwsh'. | |
String powershellBinary = "powershell"; | |
String powershellArgs; | |
if (launcher.isUnix()) { | |
powershellArgs = "-NoProfile -NonInteractive"; | |
} else { | |
powershellArgs = "-NoProfile -NonInteractive -ExecutionPolicy Bypass"; | |
} | |
args.add(powershellBinary); | |
args.addAll(Arrays.asList(powershellArgs.split(" "))); | |
args.addAll(Arrays.asList("-Command", cmd)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you do not have to - but it is generally good practice to do so.
thus if you follow good practices then this will not work
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
despite this being a String it is not currently user editable from jelly so I guess this is a moot point
@dwnusbaum I'd appreciate you casting a review, so if there is anything that needs changing. That would be favorable 😸 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
|
||
@DataBoundSetter | ||
public void setPowershellBinary(String powershellBinary) { | ||
this.powershellBinary = powershellBinary; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it make sense to do some validation here, or do you intentionally want to let users specify anything in case they've set up a symlink or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The UI only allows two options however from API it could by anything.
Do you see an issue with that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking into it some more, since jenkinsci/workflow-durable-task-step-plugin#122 is the only way users would be exposed to the change, and they wouldn't specify the actual binary, just the new pwsh
step, I don't think validation is necessary.
It seems a bit confusing that we even have Jelly files in this plugin, since IIUC they are not currently used anywhere, because the steps in workflow-durable-step define their own config and help files?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The jelly files here should appear in FreeStyle but as I wrote in the PR description. This does not currently work for master branch nor this PR.
Should I try and do a git bisect to determine when PowerShell option disappeared from Jelly view?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that feature was provided by this plugin: https://github.com/jenkinsci/powershell-plugin?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, do you mind if I switch the powershell
and pwsh
to public static final string or do you prefer enum?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure what you mean, I think the code in the PR is good as-is, no changes necessary. I'm happy to merge it once the CI build passes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Okay 👍
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like the CI build is unavailable? Getting a 503 page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I think ci.jenkins.io is down right now (unfortunately a common occurrence these days). Looks like the infra team is investigating based on #jenkins-infra on IRC.
src/main/resources/org/jenkinsci/plugins/durabletask/PowershellScript/config.jelly
Outdated
Show resolved
Hide resolved
Triggering CI 😰 |
Ci passed |
🚢 📦 🚀 |
I'd really like for pwsh step to be available. So I would appreciate a release 😓 |
@Casz Looks like master is having an issue right now, hopefully it's just infra issues (unable to build windows image for tests). Once I get those resolved I'll get a release out. |
Upstream of jenkinsci/workflow-durable-task-step-plugin#122
added docker fixture test for
pwsh
.This should allow us to create a
pwsh
step inworkflow-durable-task-step
resolves #55
resolves #73
resolves #88