-
Notifications
You must be signed in to change notification settings - Fork 21
feat(windows-plugin): add cmd.exe-based plugin for executing .exe fil… #242
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
base: master
Are you sure you want to change the base?
Conversation
…es and interacting with local file system (#2510)
Just a small note for the future, if you could use GitHub Keywords when opening PRs to connect it to the proper issue (to automate the entire process a bit more), it would be super helpful to us. You can read a bit more about it here (I've added closing keyword for this particular issue). |
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.
Good job, well done!
Could you remove the bin
folder from the PR please and add plugin-script-windows/bin
to the .gitignore
?
Also, could you add a sanity check flow test (by adding a full flow in YAML in src/test/resources)?
Finally, maybe it could make also sense to have a second task Script
taking batch script as a Strig property (like it's done in .bat
files even if Powershell is a more modern approach for Windows scripts) like this one:
@echo off
echo Hello World!
REM
What do you think about this last one @anna-geller ?
attributes( | ||
"X-Kestra-Name": project.name, | ||
"X-Kestra-Title": "Windows Command Task", | ||
"X-Kestra-Group": project.group + ".windows", |
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.
"X-Kestra-Group": project.group + ".windows", | |
"X-Kestra-Group": project.group + ".scripts.windows", |
) | ||
} | ||
) | ||
public class WindowsCmdTask implements RunnableTask<WindowsCmdTask.Output> { |
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.
Could you rename the task like this so that it follows the other plugin-scripts
tasks naming please?
cc @anna-geller What do you think about it?
public class WindowsCmdTask implements RunnableTask<WindowsCmdTask.Output> { | |
public class Commands implements RunnableTask<WindowsCmdTask.Output> { |
@Example( | ||
title = "List files in a directory", | ||
code = { | ||
"command: \"dir\"" | ||
} | ||
), | ||
@Example( | ||
title = "Run an executable file", | ||
code = { | ||
"command: \"C:\\\\path\\\\to\\\\program.exe\"" | ||
} | ||
) |
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.
For each example, you need to provide a full flow like this:
@Example(
full = true,
title = "Execute Windows commands.",
code = """
id: execute_windows_commands
namespace: company.team
tasks:
- id: windows
type: io.kestra.plugin.scripts.windows.Commands
commands:
- dir
"""
)
@PluginProperty(dynamic = true) | ||
private String command; |
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 annotation @PluginProperty
is the old way to do. Can you please for all properties do like this?
@PluginProperty(dynamic = true) | |
private String command; | |
private Property<String> command; |
tasks: | ||
- id: windows-cmd-task | ||
name: Windows Command Task | ||
description: Execute Windows commands using cmd.exe | ||
class: io.kestra.plugin.scripts.windows.WindowsCmdTask |
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.
Where is it used?
If you add a Script task next to commands task, best to refactor the code to follow what we've done on script Shell and script Powershell plugins with Script and Commands task |
@Ben8t @aj-emerich FYI the planned syntax for this plugin is below (confirmed with @fdelbrayelle): id: windows
namespace: company.team
tasks:
- id: cli
type: io.kestra.plugin.scripts.windows.Commands
commands:
- dir
- id: script
type: io.kestra.plugin.scripts.windows.Script
script: |
@echo off
cls
rem This is a comment
echo Hello World!
pause |
@balaaparna-dev Could you also add an icon |
Thank you for the update. I’ll address the feedback and follow up shortly. |
Closes kestra-io/kestra#2510.
What changes are being made and why?
To Enable Windows Command Execution
The task supports use cases such as:
related to issue #2510.
How the changes have been QAed?
Two unit tests were implemented in the WindowsCmdTaskTest class to validate the functionality of the WindowsCmdTask implementation:
testSimpleCommand: Verifies that a valid command (echo Hello, World!) executes successfully and produces the expected output.
testInvalidCommand: Ensures that an invalid command (invalidcommand) is handled gracefully by throwing an appropriate exception.