code: @Bean
    public JobFactory<ScriptJobExecution> scriptJobFactory() {
      return new JobFactory<ScriptJobExecution>() {
        @Override
        public Job<ScriptResult> createJob(ScriptJobExecution scriptJobExecution) {
          final String name = scriptJobExecution.getName();
          final String parameterString = scriptJobExecution.getParameters();
          return progress -> {
            Map<String, Object> params = new HashMap<>();
            params.putAll(gson.fromJson(parameterString, MAP_TOKEN));
            params.put("scriptJobExecutionId", scriptJobExecution.getIdValue());
            ScriptResult scriptResult = savedScriptRunner.runScript(name, params);
            if (scriptResult.getOutputFile() != null) {
              scriptJobExecution.setResultUrl(
                  format("/files/%s", scriptResult.getOutputFile().getId()));
            }
            progress.status(format("Script output:%n%s", scriptResult.getOutput()));
            return scriptResult;
          };
        }
      };
    }
docs: The Script JobFactory bean.