Documentation/Tutorials/ CI flow

Tutorial · CI

Put your test command in a versioned flow.

This two-node example runs dotnet test, fails when the command fails, and returns the test output. Run the same file on a workstation or a self-hosted Windows CI runner.

01 / THE RESULT

A command and a visible result

The flow keeps the CI contract deliberately small. shell.run owns the command, timeout, working directory, and failure policy. output.preview exposes stdout as the terminal result.

shell.runRun testsstdout
output.previewTest outputvalue
Why this works in CI: failOnNonZeroExit is enabled. A failed test command fails the Knodr run, so the CI step receives a non-zero exit code.

02 / BUILD IN THE UI

Create the flow from two nodes

  1. 01
    Create and save the flow

    Choose File → New, then save the file as flows/ci-tests.knodrflow inside your repository.

  2. 02
    Add Run Shell Command

    Search the palette for Run Shell Command. Set the command and arguments from the table below.

  3. 03
    Add Preview

    Add a Preview node, then connect Run tests.stdout to Test output.value.

  4. 04
    Add the repository variable

    Open Project → Configuration and create REPO_DIR with the default value ..

ParameterValuePurpose
commanddotnetProgram to execute
argstest↵--configuration↵ReleaseOne argument token per line
workingDirectory{{var.REPO_DIR}}Overridable repository path
timeoutSeconds900Stop a hung test run
failOnNonZeroExittruePropagate test failure

The shell node executes the program directly. Enter each argument as a separate line; do not wrap the whole command in shell syntax.

03 / VALIDATE & RUN

Check the graph before execution

Commit the .knodrflow with the rest of the repository. It is readable JSON, so changes to commands, parameters, and connections remain reviewable.

PowerShell · from the repository root
$ knodr validate .\flows\ci-tests.knodrflow
 Flow is valid

$ knodr run .\flows\ci-tests.knodrflow `
    --var REPO_DIR="$PWD" `
    --timeout 15m

validate checks the graph structure without running the command. The runtime --var replaces the saved . only for this invocation.

04 / SELF-HOSTED CI

Run the flow as one CI step

The runner needs Knodr and the .NET SDK on PATH. This example targets a self-hosted Windows runner, where you control those installed tools.

.github/workflows/tests.yml
name: Tests

on:
  pull_request:
  push:
    branches: [main]

jobs:
  flow:
    runs-on: [self-hosted, windows]
    steps:
      - uses: actions/checkout@v4

      - name: Validate Knodr flow
        shell: powershell
        run: knodr validate .\flows\ci-tests.knodrflow

      - name: Run tests through Knodr
        shell: powershell
        run: >-
          knodr run .\flows\ci-tests.knodrflow
          --var REPO_DIR="$env:GITHUB_WORKSPACE"
          --timeout 15m
Secrets in CI: never pass credentials through --var. Map a protected CI secret to KNODR_CREDENTIAL_<NAME> and reference that credential name from the flow.

05 / ADAPT THE PATTERN

Change the command, keep the contract

Replace dotnet and its arguments with npm test, cargo test, a linter, a build, or your own checked-in script. Keep the explicit working directory, timeout, and non-zero failure behavior.