Created
September 6, 2015 21:36
-
-
Save jacekkow/f63d9f64ac1489d5ee21 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.File | |
import java.lang.Runtime | |
import org.eclipse.jgit.lib.Repository | |
logger.info("post-update: post-receive hook executing post-update script in git repository.") | |
Repository repo = gitblit.getRepository(repository.name) | |
File repoPath = new File(repo.directory.canonicalPath) | |
File updateHook = new File(repoPath, "hooks" + File.separator + "post-update") | |
logger.info("post-update: repository path: ${repoPath}") | |
if (updateHook.canExecute()) { | |
logger.info("post-update: executing ${updateHook}") | |
Process process = Runtime.getRuntime().exec([updateHook.getPath()], null, repoPath) | |
process.waitFor() | |
int exitValue = process.exitValue() | |
if (exitValue != 0) { | |
logger.error("post-update: ${updateHook} exited with code ${exitValue}") | |
} else { | |
logger.info("post update: execution succeeded") | |
} | |
} else { | |
logger.info("post-update: hook not executable, nothing to do.") | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment