diff --git a/src/main/java/org/jenkinsci/plugins/durabletask/PowershellScript.java b/src/main/java/org/jenkinsci/plugins/durabletask/PowershellScript.java index 3c8680e1..958965d7 100644 --- a/src/main/java/org/jenkinsci/plugins/durabletask/PowershellScript.java +++ b/src/main/java/org/jenkinsci/plugins/durabletask/PowershellScript.java @@ -48,6 +48,7 @@ public final class PowershellScript extends FileMonitoringTask { private final String script; private String powershellBinary = "powershell"; + private boolean loadProfile = false; private boolean capturingOutput; @DataBoundConstructor public PowershellScript(String script) { @@ -63,6 +64,11 @@ public void setPowershellBinary(String powershellBinary) { this.powershellBinary = powershellBinary; } + public boolean isLoadProfile() { return loadProfile; } + + @DataBoundSetter + public void setLoadProfile(boolean loadProfile) { this.loadProfile = loadProfile; } + public String getScript() { return script; } @@ -94,9 +100,12 @@ public String getScript() { String powershellArgs; if (launcher.isUnix()) { - powershellArgs = "-NoProfile -NonInteractive"; + powershellArgs = "-NonInteractive"; } else { - powershellArgs = "-NoProfile -NonInteractive -ExecutionPolicy Bypass"; + powershellArgs = "-NonInteractive -ExecutionPolicy Bypass"; + } + if (!loadProfile) { + powershellArgs = "-NoProfile " + powershellArgs; } args.add(powershellBinary); args.addAll(Arrays.asList(powershellArgs.split(" "))); diff --git a/src/main/resources/org/jenkinsci/plugins/durabletask/PowershellScript/config.jelly b/src/main/resources/org/jenkinsci/plugins/durabletask/PowershellScript/config.jelly index 0d561e9e..d6a7d549 100644 --- a/src/main/resources/org/jenkinsci/plugins/durabletask/PowershellScript/config.jelly +++ b/src/main/resources/org/jenkinsci/plugins/durabletask/PowershellScript/config.jelly @@ -7,4 +7,7 @@ + + +