문서의 이전 판입니다!
import com.gitblit.GitBlit import com.gitblit.Keys import com.gitblit.models.RepositoryModel import com.gitblit.models.TeamModel import com.gitblit.models.UserModel import com.gitblit.utils.JGitUtils import java.text.SimpleDateFormat import org.eclipse.jgit.lib.Repository import org.eclipse.jgit.lib.Config import org.eclipse.jgit.revwalk.RevCommit import org.eclipse.jgit.transport.ReceiveCommand import org.eclipse.jgit.transport.ReceiveCommand.Result import org.slf4j.Logger
Exporting files on post-receive hook. 대한 답변 참조
Repository r = gitblit.getRepository(repository.name) for (ReceiveCommand command : commands) { def updateType = command.type def updatedRef = command.refName logger.info("## ${command.type} - ${command.refName}") def commits = JGitUtils.getRevLog(r, command.oldId.name, command.newId.name).reverse() switch (command.type) { case ReceiveCommand.Type.CREATE: case ReceiveCommand.Type.UPDATE: case ReceiveCommand.Type.UPDATE_NONFASTFORWARD: for (def commit in commits) { // commit : org.eclipse.jgit.revwalk.RevCommit logger.info("## commit.fullMessage : ${commit.fullMessage}") // 커밋 로그 메시지 def files = JGitUtils.getFilesInCommit(r, commit) files.each { file -> // 커밋/수정된 파일 정보 file : com.gitblit.models.PathModel logger.info("## Commit File ${file.name} - ${file.path}") } } } }
boolean success = true commands.each { ReceiveCommand command -> if (...) { command.setResult(Result.REJECTED_OTHER_REASON, "${repository.name} 리포지토리에 커밋 실패"); success = false break } } .... // 스크립트 마지막에서 결과리턴 return success
List<String>으로 읽어오는것이 가능하다.data/git/[Repository]/config 파일의 [gitblit] 섹션에 문자열로 저장된다.mailingList 값Repository r = gitblit.getRepository(repository.name) Config config = r.getConfig() def mailinglist = config.getStringList('gitblit', null, 'mailingList') // 'gitblit'은 섹션명, null 은 서브 섹션, 'mailingList'는 설정 키 logger.info("## mailing list ${mailinglist}")