Search in sources :

Example 1 with GitSCMFileSystem

use of jenkins.plugins.git.GitSCMFileSystem in project blueocean-plugin by jenkinsci.

the class GitCacheCloneReadSaveRequest method invokeOnScm.

<T> T invokeOnScm(final GitSCMFileSystem.FSFunction<T> function) throws IOException {
    try {
        GitSCMFileSystem fs = getFilesystem();
        if (fs == null) {
            // Fall back to a git clone if we can't get the repository filesystem
            GitCloneReadSaveRequest gitClone = new GitCloneReadSaveRequest(gitSource, branch, commitMessage, sourceBranch, filePath, contents);
            GitClient git = gitClone.cloneRepo();
            try {
                return git.withRepository(new RepositoryCallbackToFSFunctionAdapter<>(function));
            } finally {
                gitClone.cleanupRepo();
            }
        }
        return fs.invoke(function);
    } catch (InterruptedException ex) {
        throw new ServiceException.UnexpectedErrorException("Unable to save " + filePath, ex);
    }
}
Also used : ServiceException(io.jenkins.blueocean.commons.ServiceException) GitSCMFileSystem(jenkins.plugins.git.GitSCMFileSystem) GitClient(org.jenkinsci.plugins.gitclient.GitClient)

Aggregations

ServiceException (io.jenkins.blueocean.commons.ServiceException)1 GitSCMFileSystem (jenkins.plugins.git.GitSCMFileSystem)1 GitClient (org.jenkinsci.plugins.gitclient.GitClient)1