I'm attempting to create a pre-recieve hook plugin which needs to run another jar file on the files being pushed to work. I'm attempting to package said jar with the plugin and then upload and install that to stash. I've verified that my jar is in the plugin jar. (I'm sticking it in the static folder) Here's what my code looks like so far:
public boolean onReceive(RepositoryHookContext context, Collection<RefChange> refChanges, HookResponse hookResponse) { URI fileURI = null; System.out.println("Starting plugin"); try { fileURI = JalopyCheck.class.getProtectionDomain().getCodeSource().getLocation().toURI(); } catch (URISyntaxException e) { e.printStackTrace(); }
That returns something like "reference:file:/C:/[...stuff...]/target/stash/home/plugins/.osgi-cache/transformed-plugins/[plugin + random numbers].jar" in fileURI. Is there an easier way to grab and run that jar from within the plugin on the file being pushed?
I'm also wondering how to grab the file paths so I can run my jar on them from the command line.
Community moderators have prevented the ability to post new answers.
I don't think this is possible. Oh well. I simply installed my program somewhere else on the stash server. Would've been cooler to package it with the plugin, but overly difficult at the same time.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.