ChiliProject is not maintained anymore. Please be advised that there will be no more updates.

We do not recommend that you setup new ChiliProject instances and we urge all existing users to migrate their data to a maintained system, e.g. Redmine. We will provide a migration script later. In the meantime, you can use the instructions by Christian Daehn.

SVN post commit hook to post update in an issue

Added by Adrian Gunawan at 2012-07-11 09:26 am

Hi All,

I'm wondering if svn post commit hook can automatically post update in an issue. I can see that you can use REST API, but the problem is that it is using the key as a user. What I am looking for is to map the svn user with ChiliProject's user and post by that user.

I am new to ChiliProject but I am looking forward to have a long relationship with ChiliProject and hopefully can contribute in the future - after I learn RoR :)

Thanks!


Replies (5)

RE: SVN post commit hook to post update in an issue - Added by Felix Schäfer at 2012-07-11 04:52 pm

Hello Adrian,

Adrian Gunawan wrote:

I'm wondering if svn post commit hook can automatically post update in an issue. I can see that you can use REST API, but the problem is that it is using the key as a user. What I am looking for is to map the svn user with ChiliProject's user and post by that user.

There is no way that I know of to "impersonate" another user, you'd basically need the access keys from everyone that can commit to the svn to do anything.

Other ways to achieve this would be to write a plugin for ChiliProject that hooks into the changeset fetcher (the part that parses the commit messages and associates changesets to issues), as you'd be in ChiliProject proper there you could just assign users to the updates you'd like to post. You could also write rake task to achieve what you're trying to do and call that from a post-commit hook.

RE: SVN post commit hook to post update in an issue - Added by Adrian Gunawan at 2012-07-12 03:37 am

Thanks for your reply Felix.

I'd like to have the post as soon as the commit goes in, so using post-commit hook is probably the best way to do it.

Since there is no way to have a (super) user to post an update on behalf of other user, maybe what I need is a script/plugin which can retrieve the user's token then use the REST API to post on that user.. Alternatively, the script could also insert it directly into the database. I'm not sure if this could lead into instability of chiliproject.

Do you have any guide on how to create plugin of this sorts?

Thanks

RE: SVN post commit hook to post update in an issue - Added by Felix Schäfer at 2012-07-13 11:34 pm

Adrian Gunawan wrote:

Since there is no way to have a (super) user to post an update on behalf of other user, maybe what I need is a script/plugin which can retrieve the user's token then use the REST API to post on that user.. Alternatively, the script could also insert it directly into the database. I'm not sure if this could lead into instability of chiliproject.

Inserting stuff directly into the database is very risky as you'd need to follow DB format changes.

Regarding retrieving the user access token as a super-user via REST, I'm not sure if our API provides that (it probably doesn't I'm afraid). Is writing a ruby plugin/script for this not an option for you?

RE: SVN post commit hook to post update in an issue - Added by Adrian Gunawan at 2012-07-31 10:26 am

it is an option to write ruby plugin / script but I don't know where to start.. any advice? :)

RE: SVN post commit hook to post update in an issue - Added by Felix Schäfer at 2012-07-31 09:58 pm

Adrian Gunawan wrote:

it is an option to write ruby plugin / script but I don't know where to start.. any advice? :)

You can use the Rails console in ChiliProject to try out stuff. script/console gives you a console, script/console production gives you a console to the production environment (caution: everything you do there is on your production data!) and script/console -s gives you a sandboxed console (it's wrapped in a transaction and rolled back when you exit).

You can then write a Ruby script in the ChiliProject environment by using #!/path/to/ChiliProject/script/runner (you have to add the option to access the production environment, can't remember it off the top of my head though). Or you can write a rake script, have a look at those in the lib/tasks directory, you can then wrap this rake task in a plugin for easier deployment.

Lastly, you can write a full plugin, there's a little documentation at Plugin Development, some more on redmine.org, and you can naturally look at the existing ones listed in Plugin Compatibility.

(1-5/5)