Skip to content

Introduce ScriptTrigger & CommandsTrigger for the PowerShell plugin - #436

Merged
Malaydewangan09 merged 5 commits into
kestra-io:mainfrom
InnoxCodes:feature/powershell-script-commands-triggers
Sep 23, 2026
Merged

Malaydewangan09 merged 5 commits into
kestra-io:mainfrom
InnoxCodes:feature/powershell-script-commands-triggers

Conversation

@InnoxCodes

@InnoxCodes InnoxCodes commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #431, part of #313. plugin-scripts wants every submodule to expose a ScriptTrigger and a CommandsTrigger, so a flow can be triggered whenever the underlying script/commands execution completes, with an exit condition deciding whether the trigger fires. plugin-script-powershell was missing both.

Implementation

Ports the pattern already established in plugin-script-go and plugin-script-node (checked both as reference implementations, per the issue), with the edge state kept in the namespace KV store instead of an in-memory field. A polling trigger that:

  • Runs the sub-plugin's Script/Commands task once per poll
  • Matches the rendered exitCondition against either the exit code (exit N) or a regex/substring against the emitted vars. A failed run has no vars, so only exit N can match a failure
  • Supports edge mode (default on) to emit only on a not-matching-to-matching transition, so the trigger doesn't fire repeatedly on every poll while the condition stays true. The previous result is stored in the namespace KV store under a length prefixed key built from the flow and trigger ids, and it survives the trigger being rebuilt between polls. The write is skipped when a poll repeats the previous result, so a condition that stays true for hours does not rewrite the same value every interval

ScriptTrigger wraps io.kestra.plugin.scripts.powershell.Script; CommandsTrigger wraps io.kestra.plugin.scripts.powershell.Commands. Both default containerImage to ghcr.io/kestra-io/powershell:latest, matching the existing Script/Commands tasks' own default. The module doc has a Triggers section and AGENTS.md lists both classes.

Testing

Ran locally with Docker, 28 tests across these four classes, all passing:

  • ScriptTriggerTest (13): pure condition-matching unit tests that call the real package-private matchesCondition, no Docker needed
  • EdgeStateTest (10): edge state in the KV store, no Docker needed. Each poll runs on a JSON round-tripped copy of the trigger, and there are cases for edge: false, for state being scoped per flow and per trigger, for the key format, and for the write being skipped on a repeated result (checked against the KV entry's version, which stays put across repeats and increments on a real transition). Removing either kvStore.put makes the matching tests fail
  • ScriptTriggerEvaluateTest (3): runs the real ScriptTrigger#evaluate in a container (fires on exit 1, stays quiet on exit 0, suppresses the second poll in edge mode)
  • CommandsTriggerTest (4): same for CommandsTrigger. Its edge test now runs the second poll on a serialized copy and also fails without the KV write
  • ./gradlew :plugin-script-powershell:spotlessCheck fails, but only on Commands.java, which has a pre-existing violation on main unrelated to this PR

🤖 AI-assisted: I used Claude Code to help draft and verify this fix, and cross-checked it against the existing Go/Node reference implementations before opening this PR.

@github-project-automation github-project-automation Bot moved this to To review in Pull Requests Sep 16, 2026
@fdelbrayelle
fdelbrayelle requested review from a team and Malaydewangan09 September 16, 2026 10:40
@fdelbrayelle fdelbrayelle added the kind/external Pull requests raised by community contributors label Sep 16, 2026
@MilosPaunovic MilosPaunovic added the area/plugin Plugin-related issue or feature request label Sep 16, 2026
@Malaydewangan09

Copy link
Copy Markdown
Member

Ran this locally. All 17 tests pass including the 4 Docker ones you couldn't run, the powershell image is fine and both test commands behave as expected under pwsh. So the thing works.

Two things I'd want fixed before merge.

edge doesn't actually do anything. Polling triggers get dispatched to a worker as a serialized payload, and lastMatched is an AtomicBoolean with no getter, so it never survives the hop. The serialized trigger:

{"id":"t","type":"...ScriptTrigger","script":"exit 1","exitCondition":"exit 1"}

No lastMatched. Simulating the per-poll round trip the worker does:

poll#1 edge=true fired=true
poll#2 edge=true fired=true
poll#3 edge=true fired=true

It re-fires on every poll, which is the opposite of what the property promises. And commandsTrigger_edgeModeShouldSuppressSecondEmission only passes because it reuses the same object in memory. It's green while asserting something that never holds in production. That bothers me more than the bug itself, because it'll block whoever tries to fix it later.

ScriptTriggerTest doesn't test ScriptTrigger. It re-implements matchesCondition as exitConditionMatches inside the test and asserts against the copy. The real method is private and never called, so you could empty out the body and all 9 stay green. Ruby already does this right in ScriptTriggerConditionTest: makes matchesCondition package-private and calls it directly with a @CsvSource table. Worth copying.

Smaller stuff:

  • Docs say the condition is matched "against emitted vars and failure logs". There are no failure logs. buildHaystack only returns vars.toString(), and the failure path passes null vars, so on a failed run nothing except exit N can ever match. Inherited from the others, but let's not add a sixth copy of a wrong doc.
  • @EqualsAndHashCode includes the AtomicBoolean, so two identically built triggers aren't equal and hash differently. Needs @EqualsAndHashCode.Exclude.
  • The trigger only exposes containerImage and script/commands. No env, inputFiles, namespaceFiles, or docker options, so no secrets and no memory limits on a container that restarts every 60s forever. Also means CommandsTrigger can't run an existing .ps1 from namespace files, which is the main use of the Commands task.
  • You used go as the reference, which is the oldest of the five. Python (feat(python): add ScriptTrigger and CommandsTrigger with tests #338) already factored this into AbstractPythonTrigger and comes in at 83 lines instead of 275, and ruby's ScriptTrigger has a literal TODO saying to extract this into an AbstractScriptTrigger in plugin-script.
  • spotlessCheck doesn't pass, but it's pre-existing on Commands.java in main, not your files. Just worth correcting in the description.
  • Example uses PT10S. Cold start was 46s for me, warm runs 2-4s. allowConcurrent is false by default so nothing overlaps, but it reads optimistic.

The duplication is not on you, it's on us for letting it reach five copies. I'll open a separate issue for the AbstractScriptTrigger refactor so this PR doesn't have to carry it.

@InnoxCodes

Copy link
Copy Markdown
Contributor Author

Thanks for actually running this and for the depth here. Confirmed both main points independently before touching anything, pushed a fix for what's safely scoped to this PR:

edge / lastMatched: confirmed your finding exactly - it's a plain AtomicBoolean with no exposed getter, so it doesn't survive the worker's serialize/deserialize round trip, and edge mode degenerates to "fires on every matching poll" in a real distributed deployment. I didn't attempt a full fix here: this exact pattern is copied from the already-merged go/node plugins and exists identically in python/ruby/shell too, so a correct fix needs an actual mechanism for persisting state across a serialized worker dispatch, which is a design question for the whole family, not something to solve unilaterally in a PowerShell-port PR. What I did do:

  • Added an explicit code comment on lastMatched stating the limitation directly (dispatched as a serialized payload, no getter, doesn't survive the round trip, degenerates to firing every matching poll).
  • Corrected the edge property's schema description to say "intended to" rather than asserting it works.
  • Added the same limitation note on commandsTrigger_edgeModeShouldSuppressSecondEmission, since it's still only proving same-instance dedup.

Happy to pick this up properly once you've opened the AbstractScriptTrigger tracking issue - would rather fix it once, correctly, across all five, with your input on the right persistence mechanism, than patch around it here.

ScriptTriggerTest doesn't test ScriptTrigger: fixed by copying Ruby's ScriptTriggerConditionTest pattern exactly - matchesCondition is now package-private, the test builds a real ScriptTrigger and calls it directly, and the exit-code cases are a @CsvSource table. Verified this actually tests production code now: temporarily broke matchesCondition's exit-code branch, confirmed the test caught it, reverted.

Smaller stuff, all fixed:

  • "failure logs" removed from both trigger's docs - buildHaystack only ever returns vars.toString(), and the failure path passes null vars, so only exit N can ever match a failed run. Documented that explicitly instead.
  • @EqualsAndHashCode.Exclude added on lastMatched on both triggers.
  • Both examples' interval changed from PT10S to PT60S, matching the coded default and your measured cold start.
  • PR description spotlessCheck claim: you're right, it's Commands.java on main, unrelated to my files - I'll fix the description.

Not touched, intentionally deferred rather than silently dropped:

  • env/inputFiles/namespaceFiles/docker options - agreed this is a real gap (no secrets, no memory limits, CommandsTrigger can't run an existing .ps1). This felt like scope creep for a trigger-parity PR and inherits the same gap from go/node, so I'd rather do it as a deliberate follow-up than rush it in here.
  • Adopting the leaner AbstractPythonTrigger/Ruby TODO pattern - agreed, but that's exactly the refactor you said you'd track separately, so I left this PR matching the existing (if imperfect) go/node shape rather than defining a new abstraction unilaterally.

All 13 non-Docker ScriptTriggerTest tests pass locally against the real method; still don't have Docker available to re-run the 4 integration tests, but nothing in this diff touches their code paths.

🤖 AI-assisted, as disclosed in the PR description - I read and verified all of the above myself rather than taking your comment at face value.

@Malaydewangan09

Malaydewangan09 commented Sep 17, 2026 •

Copy link
Copy Markdown
Member

Pulled 2194648, re-ran everything. 21/21 including the Docker tests.

Verified fixed: matchesCondition is package-private and the test calls it for real (mutation-tested it, broke the exit-code branch, 4 tests failed). PT10S to PT60S. Exclude is on the field and the bytecode confirms equals() no longer touches lastMatched. Honest wording on edge.

One miss: ScriptTrigger.java:47, the class-level @Schema(description = ...), is unchanged from the first commit. Still says "Supports edge mode to emit only on transitions ... matched against emitted vars and failure logs", both claims you corrected everywhere else. That's the description rendered in the UI, so it's the most-read one of the set. CommandsTrigger's is clean.

Correction on my side: the Exclude works but doesn't do what its comment claims. Two identically built triggers are still unequal. Real cause is lombok.equalsAndHashCode.callSuper = call in our lombok.config plus AbstractTrigger having no equals, so every trigger's equals opens with an Object.equals identity check. Kestra-wide, not yours, and nothing depends on it. Keep the Exclude, just drop the "so two identically built triggers still compare equal" part of the comment.

Fix line 47 and I'm happy. The deferrals are the right calls, tracking issue coming.

@InnoxCodes

Copy link
Copy Markdown
Contributor Author

Thanks for the mutation test and for catching both of these.

Class-level description: you're right, ScriptTrigger.java:47 was unchanged since the first commit - fixed now to match the corrected wording on edge/exitCondition. CommandsTrigger's was already accurate, left as-is.

The Exclude comment: verified your explanation independently before touching anything - checked lombok.config (equalsAndHashCode.callSuper = call) and AbstractTrigger (no equals() override, so it's plain Object identity). You're right that callSuper means every generated equals() opens with that identity check regardless of what's excluded, so two "identically built" triggers are never equal no matter what I do here - that's pre-existing and kestra-wide, not something this PR touches or fixes. Kept @EqualsAndHashCode.Exclude (still correct: it keeps this specific mutable field out of the comparison, which is the right call for a field mutated during evaluate()), corrected the comment to describe only what it actually does instead of the broader claim.

🤖 AI-assisted - verified both independently against the actual lombok config and AbstractTrigger source rather than taking the correction at face value.

@Malaydewangan09

Malaydewangan09 commented Sep 18, 2026 •

Copy link
Copy Markdown
Member

38d9065 looks right. Class-level description is honest now and the Exclude comment describes what it actually does. Both verified.

Two things still open:

  • extractFailure only picks up an exit code when a TaskException is in the cause chain. If the container never starts (bad image, pull failure) there isn't one, exitCode stays null, and exit 1 doesn't match. A trigger configured specifically to catch failures stays silent on a real failure. I confirmed this on the Deno copy of the same code: bad image tag, exitCondition: exit 1, edge: false, trigger did not fire.
  • The user-supplied regex is recompiled on every poll. EXIT_CONDITION_PATTERN is cached in a static, this one isn't.

Neither is introduced by you and both exist in all six copies, so I'm fine treating them as part of the same family cleanup rather than blocking here. Flagging so they don't get lost.

Part of kestra-io#313. plugin-scripts wants every submodule to expose a
ScriptTrigger and a CommandsTrigger so a flow can be triggered whenever
the underlying script/commands execution completes, with an exit
condition deciding whether the trigger fires. plugin-script-powershell
was missing both.

Ports the pattern already established in plugin-script-go and
plugin-script-node (the two existing reference implementations checked
against): a polling trigger that runs the sub-plugin's Script/Commands
task once per poll, matches the rendered exitCondition against either
the exit code ('exit N') or a regex/substring against the emitted vars
and failure logs, and supports edge mode (default on) to emit only on
a not-matching-to-matching transition.

- ScriptTrigger wraps io.kestra.plugin.scripts.powershell.Script
- CommandsTrigger wraps io.kestra.plugin.scripts.powershell.Commands
- Both default containerImage to 'ghcr.io/kestra-io/powershell:latest',
  matching the existing Script/Commands tasks' default

Fixes kestra-io#431
- ScriptTriggerTest no longer duplicates matchesCondition's logic in a
  private test helper (exitConditionMatches). matchesCondition is now
  package-private and the test calls it directly on a real ScriptTrigger
  instance, matching plugin-script-ruby's ScriptTriggerConditionTest
  pattern. Before this, the test asserted against a hand-copied
  reimplementation and would have stayed green even if the real method's
  body were emptied out.
- Documented the lastMatched/edge-mode limitation instead of leaving it
  silently broken: polling triggers are dispatched to a worker as a
  serialized payload with no getter for lastMatched, so it never
  survives that round trip. In a real distributed deployment, edge mode
  currently degenerates to firing on every matching poll rather than
  only on a not-matching-to-matching transition. Added this as an
  explicit code comment and corrected the edge property's schema
  description, and added the same note to CommandsTriggerTest's
  edge-mode test, which only proves same-instance dedup. Fixing the
  underlying cross-poll state problem needs a real mechanism for
  persisting state across a serialized worker dispatch, which affects
  the whole plugin-script-go/node/python/ruby/shell family this pattern
  was copied from, not just this PR - deferring that to the
  AbstractScriptTrigger tracking issue rather than a narrow, unreviewed
  fix here.
- Added @EqualsAndHashCode.Exclude on lastMatched so two identically
  built triggers still compare equal (AtomicBoolean has no useful
  identity-independent equals).
- Corrected the exitCondition docs: the failure path never has vars to
  match against, so "failure logs" was never actually reachable -
  documented that only 'exit N' can match a failed run.
- Example intervals changed from PT10S to PT60S, matching the
  documented/coded 60s default and the reviewer's measured cold-start
  time.

Reviewed-by: Malaydewangan09
- ScriptTrigger's class-level @Schema description still said "Supports
  edge mode to emit only on transitions... matched against emitted
  vars and failure logs" - the same overclaims already corrected on
  the edge and exitCondition properties, just missed at the class
  level. CommandsTrigger's class-level description was already
  accurate.
- The lastMatched comment claimed @EqualsAndHashCode.Exclude makes two
  identically built triggers compare equal. That's wrong: this
  project's lombok.config sets equalsAndHashCode.callSuper=call, and
  AbstractTrigger has no equals() override, so every generated
  equals() opens with Object's reference-identity check regardless of
  which fields are excluded. Two distinct instances are never equal no
  matter what. Corrected the comment to say what the exclusion
  actually does (keeps this mutable field itself out of equality) and
  note the identity-equals behavior is pre-existing and unrelated to
  it.

Reviewed-by: Malaydewangan09
The edge flag lived in an AtomicBoolean on the trigger, but a polling
trigger is rebuilt on every poll, so with the default edge=true a
condition that stays true fired on every interval. The previous result
is now stored under a length prefixed key built from the flow and
trigger ids in the namespace KV store and updated on every poll.

Also:
- an empty exitCondition now fails with a clear message instead of
  silently never matching
- class level @Schema descriptions are text blocks
- the edge tests run the second poll on a serialized copy of the trigger
- add a Docker backed ScriptTrigger#evaluate test
- add KV state tests that run without Docker
- document the triggers in the module doc and list them in AGENTS.md
@InnoxCodes
InnoxCodes force-pushed the feature/powershell-script-commands-triggers branch from 19dba84 to d29797d Compare September 21, 2026 13:12
@InnoxCodes

Copy link
Copy Markdown
Contributor Author

@Malaydewangan09 heads up, I pushed d29797d after your last look. It moves the edge state out of the AtomicBoolean and into the namespace KV store (key built from the flow id length, flow id and trigger id, written on every poll), so the re-fire you reproduced on every poll no longer happens. The maintainer review on the .NET port asked for exactly this, so I applied it here too instead of waiting for the shared refactor.

Beyond that it adds EdgeStateTest (runs each poll on a serialized copy of the trigger, no Docker), a Docker backed ScriptTrigger#evaluate test, makes the edge test in CommandsTriggerTest use a serialized copy for the second poll, and has an empty exitCondition fail with a clear message. I ran everything locally with Docker: 28 tests across the four trigger test classes pass, and removing the KV write makes the edge tests fail. The extractFailure null exit code and the per-poll regex compile are still as they were, since you were fine leaving those for the family cleanup.

@Malaydewangan09

Copy link
Copy Markdown
Member

d29797d fixes it. 32/32 pass here with Docker.

I re-ran the reproduction that started this, full evaluate() path against a real container, trigger reserialized every poll, stable TriggerContext:

edge=true   poll1=FIRED  poll2=quiet  poll3=quiet
edge=false  poll1=FIRED  poll2=FIRED

That was FIRED FIRED FIRED before. The KV key construction is safe: flow ids are ^[a-zA-Z0-9][a-zA-Z0-9._-]* and trigger ids ^[a-zA-Z0-9][a-zA-Z0-9_-]*, both subsets of the KV key charset, and the length prefix does rule out the collision you mention. EdgeStateTest is a good test, the poll sequence covers the transitions that matter.

Three small things on the KV handling, none blocking:

  • shouldEmit is called outside the try/catch that wraps runOnce. A container failure is swallowed and returns empty, but a KV read or write failure propagates out of evaluate(). That asymmetry looks unintended, though failing loudly on a KV outage is arguably the better half of it.
  • kvStore.put runs on every poll even when the value is unchanged. A trigger on the default 60s interval writes ~1440 times a day to say the same thing. Writing only when matched != previouslyMatched would cut that to transitions.
  • The entry has no TTL, so it outlives the flow it belongs to. Not harmful, just never cleaned up.

Everything else from the .NET review landed here too: class-level @Schema is a text block, ## Triggers is in the package doc, AGENTS.md lists both classes, exitCondition throws instead of degrading to "", and ScriptTriggerEvaluateTest covers the happy path through evaluate.

Good from me.

…powershell)

With the default 60s interval, a condition that stays matched or stays
unmatched wrote the same value to the namespace KV store on every
single poll for no reason. Now the write only happens when the poll
actually changes the result. Same fix as the .NET PR, which is where
this came up first. Verified with a test that checks the KV entry's
version stays put across repeated polls and still increments on a real
transition, and that removing the guard makes it fail.
@InnoxCodes

Copy link
Copy Markdown
Contributor Author

Thanks for the close re-check, and for calling out the reproduction numbers, that is exactly the sequence this was supposed to fix.

Pushed f780479 for the write amplification one: the KV write is now skipped whenever the poll repeats the previous result, only an actual transition writes. Added a test that reads the KV entry back and checks its version does not move across repeated polls but does increment on a real transition, so the skip is actually proven rather than just claimed. Same fix went to the .NET PR since you raised it here first.

Left the other two as you suggested:

  • the shouldEmit/try-catch asymmetry: agreed a KV failure should not be silently absorbed the way a container failure is. If the store cannot be read or written, that is closer to an infra problem than "the script did not match" and I would rather the scheduler see the exception and retry than have the trigger quietly assume "not matched" and potentially miss a real transition.
  • no TTL on the entry: I looked at KVMetadata, it does support one, but the safe value depends on the poll interval, which is user-configured and can be anything. Get it wrong and the entry expires while the flow is still polling, which reintroduces the exact bug this PR fixes. I would rather leave it unbounded than guess.

@Malaydewangan09

Copy link
Copy Markdown
Member

f780479 is good. 34/34 pass here.

The thing I wanted to be sure the write-skip hadn't broken is the transition detection itself, since state is now only persisted on a change. Ran a full cycle in both directions through evaluate() with real containers, trigger reserialized every poll, stable context:

cmds : exit 1  exit 1  exit 0  exit 0  exit 1
got  : FIRED   quiet   quiet   quiet   FIRED

Both edges land where they should, so the optimization is behaviour preserving. Reading the version back rather than asserting on a mock is the right way to have tested it.

Agreed on leaving the other two, and your reasoning is better than my original note on both:

  • the KV failure case, you're right that there's no safe default. Swallowing it means picking between a spurious fire and a missed transition, and neither is better than letting the scheduler see it and retry.
  • the TTL, agreed. Any value has to exceed the poll interval, that's user configured and unbounded, and an entry expiring under an active flow puts back exactly the bug this fixes. Unbounded is the correct call. The orphaned-entry cleanup is a Kestra-wide housekeeping question, not something this PR should invent.

Nothing left from me on this one.

@Malaydewangan09
Malaydewangan09 merged commit 589007c into kestra-io:main Sep 23, 2026
2 checks passed
@github-project-automation github-project-automation Bot moved this from To review to Done in Pull Requests Sep 23, 2026
@fdelbrayelle

Copy link
Copy Markdown
Member

Edition: OSS | Docker tag: develop (next: 2.1.0-SNAPSHOT)
Instance: http://mpzsa.kestra.docker.localhost:1355 (left running for manual review, docker rm -f kestra-mpzsa to stop)
Screenshots: https://claude.ai/artifact/BXFgQ7v9zZGfEhaFH3aM1H

QA summary

Flow Scenario Result
ps_script_trigger_fail ScriptTrigger example, exit 1, edge true ✅ fired once, not again on later polls
ps_commands_trigger_fail CommandsTrigger example, exit 1, edge true ✅ fired once, not again on later polls
ps_script_trigger_noedge ScriptTrigger, exit 1, edge false ✅ fired on every poll (about every 12s)
ps_script_trigger_nomatch ScriptTrigger, script exit 0, condition exit 1 ✅ never fired
ps_script_task Script task (non-regression) ✅ SUCCESS
ps_commands_task Commands task (non-regression) ✅ SUCCESS

Trigger variables exposed to the flow in both edge flows: condition: exit 1, exitCode: 1.

ps_script_trigger_fail (✅ SUCCESS)

Flow YAML
id: ps_script_trigger_fail
namespace: qa.ps
triggers:
  - id: t
    type: io.kestra.plugin.scripts.powershell.ScriptTrigger
    interval: PT10S
    exitCondition: "exit 1"
    edge: true
    containerImage: ghcr.io/kestra-io/powershell:latest
    script: |
      exit 1
tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "Triggered exitCode={{ trigger.exitCode }} condition={{ trigger.condition }}"

Gantt (screenshot)

Task Status Duration
log SUCCESS 0.03s
Total SUCCESS 0.05s

Logs synthesis (screenshot): execution started by the trigger, log task completed, no errors or warnings.
Outputs synthesis: no task outputs. Trigger vars: exitCode: 1, condition: exit 1.

ps_commands_trigger_fail (✅ SUCCESS)

Flow YAML
id: ps_commands_trigger_fail
namespace: qa.ps
triggers:
  - id: t
    type: io.kestra.plugin.scripts.powershell.CommandsTrigger
    interval: PT10S
    exitCondition: "exit 1"
    edge: true
    containerImage: ghcr.io/kestra-io/powershell:latest
    commands:
      - exit 1
tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "Triggered exitCode={{ trigger.exitCode }} condition={{ trigger.condition }}"

Gantt (screenshot)

Task Status Duration
log SUCCESS under 0.1s
Total SUCCESS 0.09s

Logs synthesis (screenshot): trigger fired, log task completed, no errors.
Outputs synthesis: no task outputs. Trigger vars: exitCode: 1, condition: exit 1.

ps_script_trigger_noedge (✅)

Flow YAML
id: ps_script_trigger_noedge
namespace: qa.ps
triggers:
  - id: t
    type: io.kestra.plugin.scripts.powershell.ScriptTrigger
    interval: PT10S
    exitCondition: "exit 1"
    edge: false
    containerImage: ghcr.io/kestra-io/powershell:latest
    script: |
      exit 1
tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "Triggered exitCode={{ trigger.exitCode }} condition={{ trigger.condition }}"

3 executions in about 25s after the flow was set to edge: false, all SUCCESS. No screenshot captured. (A first deploy of this flow had edge: true by mistake in my test setup, and correctly fired only once.)

ps_script_trigger_nomatch (✅)

Flow YAML
id: ps_script_trigger_nomatch
namespace: qa.ps
triggers:
  - id: t
    type: io.kestra.plugin.scripts.powershell.ScriptTrigger
    interval: PT10S
    exitCondition: "exit 1"
    edge: true
    containerImage: ghcr.io/kestra-io/powershell:latest
    script: |
      exit 0
tasks:
  - id: log
    type: io.kestra.plugin.core.log.Log
    message: "Triggered exitCode={{ trigger.exitCode }} condition={{ trigger.condition }}"

Trigger polled every 10s (state updated each cycle), zero executions created. No screenshot captured.

ps_script_task (✅ SUCCESS) and ps_commands_task (✅ SUCCESS)

Flow YAML
id: ps_script_task
namespace: qa.ps
tasks:
  - id: s
    type: io.kestra.plugin.scripts.powershell.Script
    script: |
      Write-Output "hello script"
---
id: ps_commands_task
namespace: qa.ps
tasks:
  - id: c
    type: io.kestra.plugin.scripts.powershell.Commands
    commands:
      - Write-Output "hello commands"

Gantt (script, commands)

Task Status Duration
s (Script) SUCCESS 1.1s
c (Commands) SUCCESS 1.1s

Logs synthesis: both completed without errors or warnings.
Outputs synthesis (script, commands): no output keys, as expected for these tasks.

Notes

  • Topology view: out of scope, the PR does not concern artifacts or a custom UI.
  • No timeouts. Every scenario resolved within 30s.
  • Setup: the develop image showed the admin setup page instead of a preconfigured admin, so I created [email protected] through the UI. Not related to the PR.
  • Not covered: persistence of edge state across a trigger rebuild, and KV write skipping. Those are covered by the unit tests in the PR but were not checked in the UI.
  • The PR branch builds at version 1.9.11-SNAPSHOT, so the deployed JARs replaced the 1.10.1-SNAPSHOT JARs in my local plugins dir.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/plugin Plugin-related issue or feature request kind/external Pull requests raised by community contributors

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

Introduce ScriptTrigger & CommandsTrigger for the PowerShell plugin

4 participants