Custom JS Code

The JavaScript code layer gives you added flexibility for more advanced pipelines. Typical reasons to use custom JS code in your pipeline:

  • Conditionally run an Action
  • Trigger functions before and after Actions are executed (Hooks)
  • Passing data between Actions
  • Transforming data before passing them between Actions

There are multiple places where JS code can be used:

  1. Main Code Layer: For adding larger complex functions, initializing variables, and when data manipulations are needed. It has built-in IntelliSense so you can see everything we provide in our SDK under the Kaholo and actions objects. For example, declaring and assigning a variable which would then be plugged into an Action Parameter Field.
    var publicIp;
    var publicIp = kaholo.execution.configuration.publicIp;
  2. Action Parameter Fields: Activate the code feature by turning on the toggle switch above a parameter field. This is used to set values dynamically when the pipeline is executed. Here you can either access the Kaholo SDK to directly insert values, invoke a function, or get a variable defined in the main Code layer. Here’s an example for accessing the results of a previously executed Action:
  3. Condition Fields: Determine whether an Action should execute. For example, basing it on a previous Action’s status: actions.myaction.status=='skipped'
    Another example for using the Condition field is to set a condition on a loop: action2Iterations < 5.
  4. Hook Fields: Run a function before or after an Action is executed. A common example is to increment a variable in a Post-execution Hook in conjunction with using the Loop and Conditional code features: action2Iterations++.

Kaholo SDK

Kaholo provides an SDK available to you in the `kaholo` namespace object.

Note: To quickly see what’s available in the Kaholo SDK, go to the Code Layer tab in the UI and start typing “kaholo”. Then you will see all the available objects in our IntelliSense and Autocomplete features.


Key Description Type
actions.<ACTION_ID>.result Final result of an action JSON or String
actions.<ACTION_ID>.executions Execution statuses for an Action Array of Objects
actions.<ACTION_ID>.executions[0].actionsExecutionId The ID of the action’s execution String
actions.<ACTION_ID>.executions[0].status Whether the action succeeded or not. Available statuses: error, success, skipped, running, stopped. String
actions.<ACTION_ID>.executions[0].startTime The date and time the action started executing Date
actions.<ACTION_ID>.executions[0].params The input value of an action’s parameter that was evaluated during this specific execution Object
actions.<ACTION_ID>.mandatory Whether the action is mandatory and should stop the pipeline or failure or not. Boolean
actions.<ACTION_ID>.name The display name of the action. String
actions.<ACTION_ID>.output Includes the plugin name, method name, parameter names, parameter values, that were used for a particular execution.

In addition, it will include the stdout, stderr and errors related to custom JS that you insert into the code layer or code fields.

actions.<ACTION_ID> The name of the plugin, that the method used in this action is a part of. String
actions.<ACTION_ID>.plugin.version The version of the plugin. String
actions.<ACTION_ID>.retries The maximum number of retries configured for this action. Default is 0. Number
actions.<ACTION_ID>.retriesLeft Updated to contain the current number of retries left for trying to execute this action before stopping it. Number
actions.<ACTION_ID>.status The status of the last execution of this action. Available statuses: error, success, skipped, running, stopped. String
actions.<ACTION_ID>.timeout The value of timeout configured for this action. Number The name of the current pipeline String The unique ID of the current pipeline String
kaholo.pipeline.configurations An array containing all available configurations for this pipeline. Each item is an object containing the name and the value of each configuration. Array Of Objects
kaholo.pipeline.configurations[0].name The name of the configuration String
kaholo.pipeline.configurations[0].value The JSON object value passed as the configuration itself. JSON Object
kaholo.execution.agent An object containing information on the agent configured to execute this pipeline, during the current execution. Object The name of the agent String
kaholo.execution.agent.attributes User assigned agent attributes that are used like tags Array Of Strings
kaholo.execution.configuration The value of the configuration that was specified for this execution. JSON Object A unique ID generated automatically for each execution. String
kaholo.execution.trigger.payload The value sent to the Webhook that caused the Pipeline to trigger Object Or String
kaholo.execution.trigger.message The description of the action that caused the trigger String
kaholo.vault.getValueByKey Access to your vault items stored in Kaholo String

Accessing Action Results

When accessing Action results, you need to reference the Action’s ID. This is a user-defined field. Let’s say you’ve created an Action and set its ID to ‘myaction’ and you want to access its result from a different Action in the pipeline. In this case, you would get the results as follows:


If the Action result returned an object that contained an “id” field that you want to access, you would access it as follows:

Tip: If you’re unsure of a particular Action’s result data structure, you should execute the pipeline once and then see what was returned by the action by navigating to the Execution Results page, clicking on the particular action, and viewing the data in the “Final Results” panel.

Accessing Configuration Data

If you want to access the current execution’s configuration data, and let’s say the configuration data is {x:6}, you can access it as follows:


To access all configurations, not just the one currently being used for the execution:


Action Statuses

If you want to get the status of an Action, for example, to set a condition for another Action to execute:


Access Trigger Payload

When a Kaholo pipeline is executed with one of our Trigger plugins, it arrives with a payload that can be accessed via the Code layer as follows:


If you want to see the actual payload of a particular execution, go to the Execution Results screen and click on the Trigger hyperlink.

Page Contents