theonedev/onedev · error · ExplicitException
Groovy script not found:
Error message
Groovy script not found:
What it means
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.
Source
Thrown at server-core/src/main/java/io/onedev/server/util/GroovyUtils.java:97
for (GroovyScript each: OneDev.getInstance(SettingService.class).getGroovyScripts()) {
if (each.getName().equals(scriptName)) {
script = each;
break;
}
}
}
if (script != null) {
if (script.isAuthorized()) {
try {
return evalScript(StringUtils.join(script.getContent(), "\n"), variables);
} catch (Exception e) {
throw new RuntimeException("Error evaluating groovy script: " + scriptName, e);
}
} else {
throw new ExplicitException("Unauthorized groovy script: " + scriptName);
}
} else {
throw new ExplicitException("Groovy script not found: " + scriptName);
}
}
public static Object evalScript(String scriptContent, Map<String, Object> variables) {
try {
Class<?> scriptClass = compile(scriptContent);
Script script;
try {
Object instance = scriptClass.getDeclaredConstructor().newInstance();
if (!(instance instanceof Script))
return scriptClass;
else
script = (Script) instance;
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
throw new RuntimeException(e);
}
script.setBinding(getBinding(variables));
return script.run();View on GitHub (pinned to d44925c47c)
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.
Example fix
// before
GroovyUtils.evalScriptByName("deploi-check", vars); // typo -> not found
// after
GroovyUtils.evalScriptByName("deploy-check", vars); // exact existing name Defensive patterns
Strategy: validation
Validate before calling
if (scriptService.find(scriptName) == null) {
throw new IllegalArgumentException("Groovy script does not exist: " + scriptName);
} Try / catch
try {
return GroovyUtils.evalScriptByName(scriptName, variables);
} catch (ExplicitException e) {
if (e.getMessage().startsWith("Groovy script not found")) {
// list available scripts / fix reference
}
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- Error evaluating groovy script:
- Unauthorized groovy script:
- Error evaluating groovy script:
- User not found: ${userName}
- Issue not found: ${referenceString}
AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06).
Data as JSON: /api/errors/82eb0b4889b2ee47.
Report an issue: GitHub.