theonedev/onedev · warning · ExplicitException

Job not found

Error message

Job not found

What it means

Thrown during post-build action processing when build.getJob() returns null — the job definition (e.g. from .onedev-buildspec or job registry) is no longer resolvable for the finished build. The error is caught immediately by the surrounding catch block and only logged as 'Error processing post build actions', so post-build actions are skipped.

Source

Thrown at server-core/src/main/java/io/onedev/server/job/DefaultJobService.java:1375

	@Transactional
	@Listen
	public void on(BuildFinished event) {
		Build build = event.getBuild();
		JobAuthorizationContext.push(build.getJobAuthorizationContext());
		Build.push(build);
		try {
			JobVariableInterpolator interpolator = new JobVariableInterpolator(build, build.getParamCombination());
			Map<String, String> placeholderValues = new HashMap<>();
			placeholderValues.put(BUILD_VERSION, build.getVersion());
			if (build.getJob() != null) {
				for (PostBuildAction action : build.getJob().getPostBuildActions()) {
					action = interpolator.interpolateProperties(action);
					if (ActionCondition.parse(build.getJob(), action.getCondition()).matches(build))
						action.execute(build);
				}
			} else {
				throw new ExplicitException("Job not found");
			}
		} catch (Throwable e) {
			String message = String.format("Error processing post build actions (project: %s, commit: %s, job: %s)",
					build.getProject().getPath(), build.getCommitHash(), build.getJobName());
			logException(message, e);
		} finally {
			Build.pop();
			JobAuthorizationContext.pop();
		}
	}

	@Override
	public boolean canPullCode(HttpServletRequest request, Project project) {
		String jobToken = SecurityUtils.getBearerToken(request);
		if (jobToken != null) {
			JobContext jobContext = getJobContext(jobToken, false);
			if (jobContext != null)
				return jobContext.getProjectId().equals(project.getId());

View on GitHub (pinned to d44925c47c)

Solutions

  1. Ensure the build spec/job definition still exists at the commit when the build completes
  2. Re-run the build with the current job definition
  3. Check the logged 'Error processing post build actions' message to confirm project/commit/job name
  4. Avoid deleting jobs or build specs while builds are in flight

Example fix

// before (implicit assumption)
for (PostBuildAction action : build.getJob().getPostBuildActions()) { ... }
// after (guard)
var job = build.getJob();
if (job != null)
    for (PostBuildAction action : job.getPostBuildActions()) { ... }
Defensive patterns

Strategy: try-catch

Validate before calling

var job = build.getJob();
if (job == null) {
    log.warn("Job definition unavailable for post build actions (build {})", build.getId());
    return;
}

Try / catch

try {
    for (PostBuildAction action : build.getJob().getPostBuildActions()) { action.execute(build); }
} catch (Exception e) {
    log.error("Error processing post build actions", e);
}

Prevention

When it happens

Trigger: Executing build.getJob().getPostBuildActions() after the build finished when the job definition cannot be found — e.g. the build spec was removed/renamed, or the job cache entry was evicted before post-build ran.

Common situations: Branch deleted or .onedev-buildspec changed/removed while build was running; project restructure during the run; server restart between job completion and post-build handling.

Understand the failure class

Background: "Not found" and "does not exist" errors: why "Task not found", "No such folder", and "Can't find" fire when a lookup comes back empty — this error's family across 14 libraries.

Related errors


AI-assisted analysis of theonedev/onedev@d44925c47c (2026-09-06). Data as JSON: /api/errors/21964c28f6aa4056. Report an issue: GitHub.