Skip to main content

Run Script job

In briefA Run Script job runs a script you type into the job — PowerShell, Bash, Python or Shell — on a Universal Agent machine. The agent writes the script to a temporary file, runs it with the matching interpreter, and then removes the file. Success is decided by the same rules as Run Command: exit code 0 by default, or your own exit criteria and output parsing.

WhereIn Design › Workflows, open a workflow and open the job in the Job Editor (open its context menu on the canvas › Edit Job). On the Job Definition tab, choose Run Script as the job type, set the fields under Job Parameters, and pick a Universal Agent under Agent Assignment.

WhenUse a Run Script job when:

  • the logic is more than one command line;
  • the script belongs to this one job, rather than being shared by many;
  • the script's exit codes or output need their own success rule.

For a single command, use Run Command. To share one script across jobs on legacy Windows or UNIX machines, store it in the script library.

How

  1. Choose Run Script as the job type and choose the Script Type.
  2. Enter the Script Content, and any Script Arguments, Working Directory or Environment Variables.
  3. Add Exit Criteria or Output Parsing rules if the default rule does not fit.
  4. Assign the job to a Universal Agent and save.

For the full steps, see Run a script.

Notes
  • The interpreter must already be installed on the agent machine. PowerShell on Linux or macOS needs pwsh.
  • PowerShell runs with -NoProfile, so the script cannot rely on a profile.
  • An exit criterion that matches means the job failed. With criteria set, Fail on Error is ignored.
  • A script can set its own exit code. That is often simpler than parsing its output.
Watch out
  • A new job starts with Script Type shell. Choose the type that matches the script before you save, or the script runs with the shell interpreter.
  • A script longer than 65,536 characters is refused.
  • Every Run Script job stops after one hour, and no setting changes that. Kill does not stop the script on a Universal Agent.
  • Only the first and last 512 KB of each output stream are searched by output parsing.