gnustavo / Git-Hooks

Framework for implementing Git (and Gerrit) hooks
http://search.cpan.org/dist/Git-Hooks/
41 stars 17 forks source link

Distinguish between multiple JIRA instances #61

Closed boudekerk closed 4 years ago

boudekerk commented 4 years ago

Hi,

we have two separate JIRA instances, is it possible to have two (global) plugin configurations and specify on the project which one to use without forking the plugin under a different name?

Thanks!

gnustavo commented 4 years ago

Hi,

As it is each Git repository can have only one Jira instance configured using the jiraurl, jirauser, and jirapass options. You can define these options on the local config of each repository.

Do you want to have two instances configured in the same repository? How would they be selected during a pre-receive hook, for instance? I'm not sure I get what you're aiming for...

boudekerk commented 4 years ago

Sorry, I should have provided more context.

Some of our users can configure the hooks themselves, they edit a Json that's then processed to set the config on the repositories. For obvious reasons we don't want them to set the jirauser/pass, so those are set globally on the server and they just configure the plugin and some properties like the JQL.

There's two JIRA instances, but obviously, only one will be used per project. So instead of adding more complex logic to the script that sets the properties, it would be nice if there was a way for users to simply configure plugin CheckJira1 or CheckJira2. And keep the credentials etc. in global config managed outside the script.

I hope this makes it a bit clearer

gnustavo commented 4 years ago

I see...

In this case, I think you could simply make two copies of the CheckJira.pm file in the same directory. Call them CheckJira1.pm and CheckJira2.pm. Then edit CheckJira1.pm and change the package name (4th line) to Git::Hooks::CheckJira1. Do the same to CheckJira2.pm. Then you would end up with two new plugins which you would configure like this:

[githooks]
  plugin = CheckJira1

[githooks "checkjira1"]
  jiraurl = ...
  jirauser = ...
  jirapass = ...

I haven't tried it but I think it should work.

Please, try it out and tell me how it goes.

boudekerk commented 4 years ago

Looks to be working. Thanks!

gnustavo commented 4 years ago

Great!