{"record":{"id":"82eb0b4889b2ee47","repo":"theonedev/onedev","slug":"groovy-script-not-found","errorCode":null,"errorMessage":"Groovy script not found: ","messagePattern":"Groovy script not found: ","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/util/GroovyUtils.java","lineNumber":97,"sourceCode":"        \tfor (GroovyScript each: OneDev.getInstance(SettingService.class).getGroovyScripts()) {\n        \t\tif (each.getName().equals(scriptName)) {\n        \t\t\tscript = each;\n        \t\t\tbreak;\n        \t\t}\n        \t}\n    \t}\n    \tif (script != null) {\n    \t\tif (script.isAuthorized()) {\n    \t\t\ttry {\n    \t\t\t\treturn evalScript(StringUtils.join(script.getContent(), \"\\n\"), variables);\n    \t\t\t} catch (Exception e) {\n    \t\t\t\tthrow new RuntimeException(\"Error evaluating groovy script: \" + scriptName, e);\n    \t\t\t}\n    \t\t} else {\n    \t\t\tthrow new ExplicitException(\"Unauthorized groovy script: \" + scriptName);\n    \t\t}\n    \t} else {\n    \t\tthrow new ExplicitException(\"Groovy script not found: \" + scriptName);\n    \t}\n    }\n    \n    public static Object evalScript(String scriptContent, Map<String, Object> variables) {\n    \ttry {\n\t    \tClass<?> scriptClass = compile(scriptContent);\n\t\t\tScript script;\n\t\t\ttry {\n\t\t\t\tObject instance = scriptClass.getDeclaredConstructor().newInstance();\n\t\t\t\tif (!(instance instanceof Script))\n\t\t\t\t\treturn scriptClass;\n\t\t\t\telse \n\t\t\t\t\tscript = (Script) instance;\t\t\t\t\t\n\t\t\t} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {\n\t\t\t\tthrow new RuntimeException(e);\n\t\t\t}\n\t\t\tscript.setBinding(getBinding(variables));\n\t\t\treturn script.run();","sourceCodeStart":79,"sourceCodeEnd":115,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/util/GroovyUtils.java#L79-L115","documentation":"GroovyUtils.evalScriptByName throws ExplicitException(\"Groovy script not found: <scriptName>\") when no script with the given name can be located. This is an expected user-facing error for a bad or renamed script reference.","triggerScenarios":"Calling evalScriptByName(\"name\", vars) where no script of that name exists — typos, scripts deleted or renamed, or referencing a script from another project/scope that isn't visible.","commonSituations":"Copy-pasting job/build definitions between servers where the script wasn't recreated, case-sensitivity mismatches in script names, scripts removed during cleanup, or branch/export/import flows missing script definitions.","solutions":["Check the exact script name in administration > scripts (or project scripts) and fix any typo.","Recreate the script on the target server if it exists only elsewhere.","Verify script name case matches exactly — lookups are typically case-sensitive.","If referenced from an exported job spec, import the script definition along with it."],"exampleFix":"// before\nGroovyUtils.evalScriptByName(\"deploi-check\", vars); // typo -> not found\n// after\nGroovyUtils.evalScriptByName(\"deploy-check\", vars); // exact existing name","handlingStrategy":"validation","validationCode":"if (scriptService.find(scriptName) == null) {\n    throw new IllegalArgumentException(\"Groovy script does not exist: \" + scriptName);\n}","typeGuard":null,"tryCatchPattern":"try {\n    return GroovyUtils.evalScriptByName(scriptName, variables);\n} catch (ExplicitException e) {\n    if (e.getMessage().startsWith(\"Groovy script not found\")) {\n        // list available scripts / fix reference\n    }\n}","preventionTips":["Reference scripts by exact, case-correct name; prefer constants over inline literals.","When exporting/importing job specs, include dependent script definitions.","Periodically check for dangling script references after renames/deletions."],"tags":["groovy","scripting","not-found"],"backgroundTag":"resource-not-found","analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}