I'm looking for a part-time remote job.

Hire me


I'm the author of:

Mastering Redmine is a comprehensive guide with tips, tricks and best practices, and an easy-to-learn structure.

Check the book's project or

Buy the book

Social pages of the book:

By buying this book you also donate to Redmine (see this page).


Follow me:

Feature #1870

Adding creation and deletion external script option

Added by Blaž Podržaj over 9 years ago. Updated about 9 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Target version:
Start date:
14 Oct 2011
Due date:
05 Nov 2011
% Done:

100%

External issue:

Description

Hi,

I have a proposal for a feature that might come handy. It would be like an extended “copy hooks” feature.

On a Settings→Repository view (or in scm.yml for a start) you could add two additional input fields (options)... one called “external system creation script” and another “system deletion script”. The input would be the system path to a (shell) script being executed upon creation and deletion of a repo. Plugin could also export repo_name as a first argument ($1) to those two scripts.

Example for creation would be a script that does some sanity check on a repo (permissions/owner/group of a repo directory), could also copy hooks, make some initial directories (trunk/branches/tags) in that repo etc.

Example for deletion would be a script that does archiving (zip/tar.gz) and moving the archive somewhere else on the system before actualy deleting it.

Regards,

B


Related issues

Related to SCM Creator (+Github) - Support #1886: Going to make hooks obsolete... Should I? Closed 01 Nov 2011 06 May 2014

History

#1 Updated by Jonas Götze over 9 years ago

+1
I was just searching for a way to achive this. In my case I would like to be able to select the post-commit-hook that will be copied for the newly created repository. If I could register such a creation script I could do that by having different creation-scripts available which copy the correct hooks and perhabs also do some other things (e.g. do a checkout of the project to /var/www/myProject for testing).

Also it would be nice if you could pass parameters to the scripts (e.g. a path to checkout to in /var/www). Perhabs you could use a textfield for the scriptpath and anything that follows the path will be passed as parameter... ?

Would be nice to have such a feature available!

Regards

#2 Updated by Andriy Lesyuk about 9 years ago

  • Status changed from New to Incomplete

Thanks for the suggestion!

I guess it should be in scm.yml... (Why in Settings → Repository?)

#3 Updated by Andriy Lesyuk about 9 years ago

  • Status changed from Incomplete to Open

#4 Updated by Andriy Lesyuk about 9 years ago

  • Status changed from Open to Incomplete
  • Target version set to 0.3.0

#5 Updated by Jonas Götze about 9 years ago

Andriy Lesyuk wrote:

Thanks for the suggestion!

Thanks for picking it up!

I guess it should be in scm.yml... (Why in Settings → Repository?)

Because you could select project-specific scripts or pass parameters to the script

Jonas Götze wrote:

Also it would be nice if you could pass parameters to the scripts (e.g. a path to checkout to in /var/www). Perhabs you could use a textfield for the scriptpath and anything that follows the path will be passed as parameter... ?

In my case I would need this, as we have at least 2 different project types, which need different commit-hooks. I could choose and copy the correct hook in my creation-script, but I would need some identifier (apart from projectname).
So it should be possible to either choose the fitting script on project-creation or pass a parameter to it which enables the script to decide correct.

Best would imo be if you could define some creation-/delete- scripts in scm.yml and these will be presented in a dropdown in Settings → Repository of the project along with an empty value for no script-execution at all.
The project creator would then be able to just choose one of the predefined scripts and create the repository.

What do you think?

#6 Updated by Andriy Lesyuk about 9 years ago

  • Status changed from Incomplete to Open

Well... I like scm.yml option more because in this case I won’t need another database table just for storing selected scripts.

Which arguments do you want to have in these scripts?
They can be:

$ /path/script $full_path_to_repo $project_identifier $repo_type

They can also be environment variables...

Jonas, what argument will be useful for you?

#7 Updated by Blaž Podržaj about 9 years ago

If we assume that repo name is the same as project identifier then we can use project identifier. Repo type can also help us in distingushing...

#8 Updated by Jonas Götze about 9 years ago

Andriy Lesyuk wrote:

Jonas, what argument will be useful for you?

I guess only userdefined arguments will be...
Somewhat like a creation-Profilename whith that the creation-script can work as a dispatcher.
I doubt the project-name can always garantuee that, in our case at least.

Why would you need to store them in the database?
Create and delete a project (and repository) should only occur once I guess - so I think displaying the possible values in a dropdown or something else will happen once and then dissappear like the “create new Repository"-Button does.

Perhabs somthing like this:
scm.yml

production:
   auto_create: false
   deny_delete: true
   svn:
     path: /var/lib/svn
     svnadmin: /usr/bin/svnadmin
     hooks: /usr/share/subversion/hook-scripts
     url: svn
     availablecreationscripts:
       Script1: /usr/share/subversion/do-something-on-creation.sh
       Script2: /usr/share/subversion/do-something-else-on-creation.sh
       Script3: /usr/share/subversion/do-something-weird-on-creation.sh

Which will result in a dropdown with three options labeled with “Script1",“Script2",“Script3” and the corresponding values. I don’t know if this is a good way to realize this in your case - just as example.

If no scripts are defined the dropdown will not appear at all. If there are some scripts defined, there could (should?) also be the empty (default) option so you could still create a repository and use no script at all.

Regards

#9 Updated by Andriy Lesyuk about 9 years ago

I don’t know why but I don’t like the idea of new select field... While it’s possible to show it on creation it can be impossible (or very hard) to show it on deletion... Anyway I will think about this.

Maybe some custom field value can help you? Is there anything that differs these two project types? Parent project?..

#10 Updated by Blaž Podržaj about 9 years ago

I thought this thing over and must agree that it should be only in scm.yml. The reason for this is because these are more like system settings which project admins aren’t really interested in (by definition they don’t even have access to the operating system) and they might get confused if they see such input/select fields in GUI that they know nothing about. So my vote is for:

ceationscript: <script_path>
deletionscript: <script_path>
...in scm.yml only.

#11 Updated by Andriy Lesyuk about 9 years ago

I believe the case described by Jonas is likely unusual... The plugin can’t cover all such cases! But I want to do as much as possible to help Jonas.

Jonas, what about this kind of solution (requires programming in script):

You can add a custom field e.g. “Project type” of “List” type having two possible values: e.g. “Type1” and “Type2”. Project managers will be required to select the “Project type” when creating a project. With this approach you will have a field which identifies your project types... And this field will be understandable to users unlike script names which can confuse. Having project identifier you can then fetch custom field value from database in your script... What do you think? I’m ready to help you implement such script if you agree.

#12 Updated by Jonas Götze about 9 years ago

Andriy Lesyuk wrote:

I believe the case described by Jonas is likely unusual... The plugin can’t cover all such cases! But I want to do as much as possible to help Jonas.

Thanks a lot for that! I really appreciate it.

Jonas, what about this kind of solution (requires programming in script):

You can add a custom field e.g. “Project type” of “List” type having two possible values: e.g. “Type1” and “Type2”. Project managers will be required to select the “Project type” when creating a project. With this approach you will have a field which identifies your project types... And this field will be understandable to users unlike script names which can confuse. Having project identifier you can then fetch custom field value from database in your script... What do you think? I’m ready to help you implement such script if you agree.

Thanks for your offer - this suggestion sounds promising. I did not think of such a solution.
So in my creation script I would need to select the project-Record via mysql using the project identifier passed to the script - right?
I am new to shell-Scripts so I am not sure yet how I can use the result of the Query in the Script but I think I will figure this out. With that information I could then select the fitting commit-hooks and copy them to the passed project-Repository-Path and do everything else what is needed for the project type.

Thanks again for your efforts.

Regards

#13 Updated by Andriy Lesyuk about 9 years ago

This option is going to replace hooks (see: #1886)! What do you think?

#14 Updated by Andriy Lesyuk about 9 years ago

  • Status changed from Open to In Progress
  • % Done changed from 0 to 50

Started!

New global config options: pre_create, post_create, pre_delete and post_delete...

Scripts have three arguments:
  • path e.g. /var/lib/git/download-button.git
  • type e.g. git
  • identifier e.g. download-button

Specially for you, Jonas, script will have access to project custom fields! For example, if your custom field name is “Very specific type” there will be environment variable SCM_CUSTOM_FIELD_VERY_SPECIFIC_TYPE... I believe many custom fields won’t harm scripts...

#15 Updated by Andriy Lesyuk about 9 years ago

  • % Done changed from 50 to 80

#16 Updated by Andriy Lesyuk about 9 years ago

  • Due date set to 05 Nov 2011
  • Status changed from In Progress to Closed
  • % Done changed from 80 to 100

I believe the issue has been resolved! Thanks for your suggestions!

#17 Updated by Jonas Götze about 9 years ago

Thanks for your work!

Andriy Lesyuk wrote:

Specially for you, Jonas, script will have access to project custom fields! For example, if your custom field name is “Very specific type” there will be environment variable SCM_CUSTOM_FIELD_VERY_SPECIFIC_TYPE... I believe many custom fields won’t harm scripts...

This sounds very nice. I’ll try it as soon as I have some time again Thanks again!

Regards

Also available in: Atom PDF

Terms of use | Privacy policy