Issue Overview
In certain environments, users of Deploy may encounter an error when executing PowerShell commands as part of their deployment processes. This error typically arises when attempting to execute complex PowerShell scripts and is evidenced by a failure message similar to the following:
Step failed
com.xebialabs.overthere.RuntimeIOException: Cannot start command [powershell -ExecutionPolicy
Unrestricted -InputFormat None -NonInteractive -NoProfile -Command "…"]
...
Caused by: java.io.IOException: Cannot run program "cmd": Malformed argument has embedded quote:
powershell -ExecutionPolicy Unrestricted -InputFormat None -NonInteractive -NoProfile
-Command "…"
This issue is not confined to a specific version of Deploy but is more broadly associated with how the Java Virtual Machine (JVM) used by Deploy handles command line arguments.
Root Cause
The underlying cause of this issue is the strict parsing mechanism employed by the Java ProcessBuilder
API in recent Java versions. This strictness can lead to problems when running commands that contain complex syntax or special characters, such as those often found in PowerShell scripts.
Resolution
To resolve this issue, the Java runtime environment for Deploy needs to be configured to allow for more permissive parsing of command line arguments. This can be achieved by setting a specific Java system property.
Step-by-Step Solution:
-
Locate Configuration File:
- Navigate to the [Deploy_install_dir]/conf directory.
- Find the file named xld-wrapper.conf.common.
-
Modify JVM Arguments:
- Open xld-wrapper.conf.common in a text editor.
- Add the following line to the file:
wrapper.java.additional.[X]=-Djdk.lang.Process.allowAmbiguousCommands=true
- Replace [X] with the next sequential number based on the existing configuration lines in the file (e.g., if wrapper.java.additional.6 is the last line, use wrapper.java.additional.7).
-
Restart Deploy:
- After saving the changes, restart the Deploy application to apply the new configuration.
Important Notes:
- Testing: It is highly recommended to test this change in a non-production environment before applying it to your production systems.
- Security Considerations: This setting relaxes the security constraints on command line parsing, which might potentially introduce risks if not used carefully. Ensure that the deployment scripts are from trusted sources.
Comments
Please sign in to leave a comment.