Execute a Nashorn (JavaScript) script.

This task is deprecated, please use io.kestra.plugin.graalvm.js.Eval instead.

yaml
type: "io.kestra.plugin.scripts.nashorn.eval"
yaml
id: nashorn_eval
namespace: company.team

tasks:
  - id: eval
    type: io.kestra.plugin.scripts.nashorn.Eval
    outputs:
      - out
      - map
    script: |
      var Counter = Java.type('io.kestra.core.models.executions.metrics.Counter');
      var File = Java.type('java.io.File');
      var FileOutputStream = Java.type('java.io.FileOutputStream');

      logger.info('executionId: {}', runContext.render('{{ execution.id }}'));
      runContext.metric(Counter.of('total', 666, 'name', 'bla'));

      map = {'test': 'here'}
      var tempFile = runContext.workingDir().createTempFile().toFile()
      var output = new FileOutputStream(tempFile)
      output.write('555\n666\n'.getBytes())

      out = runContext.storage().putFile(tempFile)"
Properties
SubType string

A list of output variables that will be usable in outputs.

A full script.

The captured outputs as declared on task property.

The resulting object.

Mostly the last return of eval (if the language allows it).