I'm new to Stash. We like to set up the environment so people cannot add large binary files (such as MS Office files, PDF, JAR, etc.) to the Git repository. Besides setting up global .gitignore files for each desktop and repository, it'd be nicer that Stash server could prevent push user repository with such files to the central Git repository.
Thanks and any help is greatly appreciated.
Andy,
Adaptavist have recently released an Add-on to the Atlassian Marketplace called ScriptRunner for Stash that can do exactly what you are looking for.
Our documentation outlines how you can restrict the file size for any file (including binaries) by configuring a Pre-receive hook to achieve it.
There is also a video on our Adaptavist ScriptRunner Youtube channel that will walk you through a number of Pre-receive hooks including the prevention of large files.
This screenshot shows you the Administration screen that would configure a restriction of 10MB to all files with the extension of .css and .js which you could extend to include MS Office files, PDFs and JAR files:
Screen Shot 2015-08-03 at 18.02.23.png
I hope that helps
Take a look at the Atlassian Marketplace to see if there are any pre-receive hooks that can help you. You can use ours "Javascript hooks for Stash" ( https://marketplace.atlassian.com/plugins/com.wittified.stash.js-hooks ) to do it on a per repository basis. Something like:
function verifyFiles( files) { for(var i=0;i<files.length;i++) { if(files[i].path().endsWith('.doc')) { stash.sendFeedback('Invalid file extension', files[i].path+' was in the commit. Please remove', true); } } } for(var c=0;c<changeSet.length;c++) { var commits = stash.fetchCommits( project.key, repository.slug, changeSet[c].fromHash , changeSet[c].toHash); for(var commitCounter=0;commitCounter<commits.length;commitCounter++) { verifyFiles( commits[commitCounter].filesAdded); verifyFiles( commits[commitCounter].filesModified); verifyFiles( commits[commitCounter].filesMoved); verifyFiles( commits[commitCounter].filesCopied); verifyFiles( commits[commitCounter].filesUnknown); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.