Source:
<code>public Pipeline pipelineWithPasswordAwareBuildCauseByBuildId(final long buildId) { Pipeline pipeline = pipelineDao.pipelineWithMaterialsAndModsByBuildId(buildId); MaterialRevisions scheduledRevs = pipeline.getBuildCause().getMaterialRevisions(); MaterialConfigs knownMaterials = knownMaterials(pipeline, scheduledRevs); for (MaterialRevision materialRevision : scheduledRevs) { MaterialConfig materialConfig = materialFrom(knownMaterials, materialRevision); Material usedMaterial = materialRevision.getMaterial(); if (materialConfig == null) { final JobInstance jobInstance = jobInstanceService.buildByIdWithTransitions(buildId); scheduleService.failJob(jobInstance); final String message = "Cannot load job '" + jobInstance.buildLocator() + "' because material " + usedMaterial.config() + " was not found in config."; final String description = "Job for pipeline '" + jobInstance.buildLocator() + "' has been failed as one or more material configurations were either changed or removed."; <START> final ServerHealthState error = ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forJob(jobInstance.getPipelineName(), jobInstance.getStageName(), jobInstance.getName()))); <END> error.setTimeout(Timeout.FIVE_MINUTES); serverHealthService.update(error); appendToConsoleLog(jobInstance, message, description); throw new StaleMaterialsOnBuildCause(joinTwoStringsWithNewLine(message, description)); } usedMaterial.updateFromConfig(materialConfig); } return pipeline; }</code><technical_language>This is fixed in PR #6410</technical_language>

Target:
public Pipeline pipelineWithPasswordAwareBuildCauseByBuildId(final long buildId) { Pipeline pipeline = pipelineDao.pipelineWithMaterialsAndModsByBuildId(buildId); MaterialRevisions scheduledRevs = pipeline.getBuildCause().getMaterialRevisions(); MaterialConfigs knownMaterials = knownMaterials(pipeline, scheduledRevs); for (MaterialRevision materialRevision : scheduledRevs) { MaterialConfig materialConfig = materialFrom(knownMaterials, materialRevision); Material usedMaterial = materialRevision.getMaterial(); if (materialConfig == null) { final JobInstance jobInstance = jobInstanceService.buildByIdWithTransitions(buildId); scheduleService.failJob(jobInstance); final String message = "Cannot load job '" + jobInstance.buildLocator() + "' because material " + usedMaterial.config() + " was not found in config."; final String description = "Job for pipeline '" + jobInstance.buildLocator() + "' has been failed as one or more material configurations were either changed or removed."; transactionSynchronizationManager.registerSynchronization(new TransactionSynchronizationAdapter() { @Override public void afterCommit() { final ServerHealthState error = ServerHealthState.error(message, description, HealthStateType.general(HealthStateScope.forJob(jobInstance.getPipelineName(), jobInstance.getStageName(), jobInstance.getName()))); error.setTimeout(Timeout.FIVE_MINUTES); serverHealthService.update(error); appendToConsoleLog(jobInstance, message); appendToConsoleLog(jobInstance, description); } }); throw new StaleMaterialsOnBuildCause(message); } usedMaterial.updateFromConfig(materialConfig); } return pipeline; }