{"record":{"id":"eb03780542679758","repo":"theonedev/onedev","slug":"build-spec-not-defined-project-s-commit-s","errorCode":null,"errorMessage":"Build spec not defined (project: %s, commit: %s)","messagePattern":"Build spec not defined \\(project: (.+?), commit: (.+?)\\)","errorType":"exception","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/job/DefaultJobService.java","lineNumber":292,"sourceCode":"\t\t}\n\t}\n\n\t@Transactional\n\t@Override\n\tpublic Build submit(User user, Project project, ObjectId commitId, String jobName, \n\t\t\t\t\t\tMap<String, List<String>> paramMap, String refName, \n\t\t\t\t\t\tPullRequest request, Issue issue, String reason) {\n\t\tLock lock = LockUtils.getLock(\"job-manager: \" + project.getId() + \"-\" + commitId.name());\n\t\ttransactionService.mustRunAfterTransaction(() -> lock.unlock());\n\n\t\tJobAuthorizationContext.push(new JobAuthorizationContext(project, commitId, request));\n\t\ttry {\n\t\t\t// Lock to guarantee uniqueness of build (by project, commit, job and parameters)\n\t\t\tlock.lockInterruptibly();\n\n\t\t\tBuildSpec buildSpec = project.getBuildSpec(commitId);\n\t\t\tif (buildSpec == null) {\n\t\t\t\tthrow new ExplicitException(String.format(\n\t\t\t\t\t\t\"Build spec not defined (project: %s, commit: %s)\",\n\t\t\t\t\t\tproject.getPath(), commitId.name()));\n\t\t\t}\n\n\t\t\tvalidateBuildSpec(project, commitId, buildSpec);\n\n\t\t\tif (!buildSpec.getJobMap().containsKey(jobName)) {\n\t\t\t\tvar errorMessage = String.format(\n\t\t\t\t\t\t\"Job not found (project: %s, commit: %s, job: %s)\",\n\t\t\t\t\t\tproject.getPath(), commitId.name(), jobName);\n\t\t\t\tthrow new BadRequestException(errorMessage);\n\t\t\t}\n\n\t\t\treturn doSubmit(user, project, commitId, jobName, paramMap, refName, request, issue, reason);\n\t\t} catch (Throwable t) {\n\t\t\tthrow ExceptionUtils.unchecked(t);\n\t\t} finally {\n\t\t\tJobAuthorizationContext.pop();","sourceCodeStart":274,"sourceCodeEnd":310,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/job/DefaultJobService.java#L274-L310","documentation":"DefaultJobService.submit resolves the build spec (.onedev-buildspec) from the given project and commit. If the commit has no build spec defined (project.getBuildSpec(commitId) returns null), no job can run, and an ExplicitException is thrown naming the project and commit. This guard runs inside the uniqueness lock before validation and submission.","triggerScenarios":"Calling jobService.submit (directly or via run/build) with a commit that lacks a .onedev-buildspec file, or where the file is empty/not recognized as a build spec at that revision.","commonSituations":"Triggering CI on a branch that never added .onedev-buildspec; pushing to a commit before the build spec was committed; wrong refName/commit passed so the lookup hits a pre-spec history; spec file named or located incorrectly.","solutions":["Add a valid .onedev-buildspec to the repository and commit it on the target branch.","Verify the commitId/refName you submit against actually contains the build spec (browse the commit in the UI).","If using branch schedules/webhook triggers, restrict them to branches known to have the spec."],"exampleFix":"// before\ngit.push(...); jobService.submit(user, project, commitId, \"build\", ...); // spec not on branch yet\n// after\ncommitBuildSpecToBranch(\"main\"); // add .onedev-buildspec\nObjectId c = project.getRevision(\"main\").getCommitId();\nif (project.getBuildSpec(c) != null) jobService.submit(user, project, c, \"build\", ...);","handlingStrategy":"validation","validationCode":"if (project.getBuildSpec(commitId) == null)\n  throw new ExplicitException(\"No .onedev-buildspec at \" + commitId.name() + \"; add one before triggering CI\");","typeGuard":null,"tryCatchPattern":"try { jobService.submit(...); } catch (ExplicitException e) { if (e.getMessage().startsWith(\"Build spec not defined\")) notifyMissingSpec(project, commitId); throw e; }","preventionTips":["Add .onedev-buildspec to default branch and require it via protected branches","Only trigger CI on refs known to contain the spec","Verify commit contents before programmatic submit calls"],"tags":["ci","build-spec","missing-file"],"backgroundTag":"missing-required-config","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"}