{"record":{"id":"731dda0434bfa18d","repo":"theonedev/onedev","slug":"this-build-is-not-authorized-to-create-tag","errorCode":null,"errorMessage":"This build is not authorized to create tag '","messagePattern":"This build is not authorized to create tag '","errorType":"validation","errorClass":"ExplicitException","httpStatus":null,"severity":"error","filePath":"server-core/src/main/java/io/onedev/server/buildspec/step/CreateTagStep.java","lineNumber":102,"sourceCode":"\t\treturn OneDev.getInstance(SessionService.class).call(() -> {\n\t\t\tvar build = OneDev.getInstance(BuildService.class).load(buildId);\n\t\t\tPersonIdent taggerIdent = OneDev.getInstance(UserService.class).getSystem().asPerson();\n\t\t\tProject project = build.getProject();\n\t\t\tString tagName = getTagName();\n\n\t\t\tif (!Repository.isValidRefName(GitUtils.tag2ref(tagName))) {\n\t\t\t\tlogger.error(\"Invalid tag name: \" + tagName);\n\t\t\t\treturn new ServerStepResult(false);\n\t\t\t}\n\n\t\t\tif (build.canCreateTag(getAccessTokenSecret(), tagName)) {\n\t\t\t\tRefFacade tagRef = project.getTagRef(tagName);\n\t\t\t\tif (tagRef != null)\n\t\t\t\t\tOneDev.getInstance(ProjectService.class).deleteTag(project, tagName);\n\t\t\t\tOneDev.getInstance(GitService.class).createTag(project, tagName, build.getCommitHash(),\n\t\t\t\t\t\ttaggerIdent, getTagMessage(), false);\n\t\t\t} else {\n\t\t\t\tthrow new ExplicitException(\"This build is not authorized to create tag '\" + tagName + \"'\");\n\t\t\t}\n\t\t\treturn new ServerStepResult(true);\n\t\t});\n\t}\n\n}\n","sourceCodeStart":84,"sourceCodeEnd":109,"githubUrl":"https://github.com/theonedev/onedev/blob/d44925c47c37992c828ea673a5f9620539bc3ff2/server-core/src/main/java/io/onedev/server/buildspec/step/CreateTagStep.java#L84-L109","documentation":"CreateTagStep.run checks build.canCreateTag against the job authorization setting; when the build's job authorization does not include the tag name pattern, tag creation is refused. The message names the requested tag.","triggerScenarios":"Thrown at server-core/src/main/java/io/onedev/server/buildspec/step/CreateTagStep.java:102 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Add the tag name (or a matching pattern) to the job authorization setting 'Create Tag' in the build spec.","Adjust the tag name so it matches an already-authorized pattern."],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"d44925c47c37992c828ea673a5f9620539bc3ff2","analyzedAt":"2026-09-06T07:18:27.995Z","contentChangedAt":"2026-09-06T07:18:27.995Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}