scm-manager-cli and plugins

51 views
Skip to first unread message

Gildas Cuisinier

unread,
May 12, 2014, 10:45:11 AM5/12/14
to scmma...@googlegroups.com
Hello,

I want to use the cli to create automatically :

* A user XXX-Manager
* A group XXX-Group, with XXX-Manager as member
* A Repository, own by XXX-Group.

No problem with this :)

But I want  XXX-Manager to be a GroupManager for XXX-Group.
For this, i use the GroupManager Plugin.

Of course, GroupManager is not managed by default "cli".
Does it exist an extension for the CLI too ?

Or a way to extends the CLI to add some command ?

Thanks for your help,

Gildas Cuisinier

Sebastian Sdorra

unread,
May 12, 2014, 4:00:53 PM5/12/14
to scmma...@googlegroups.com
Hi,
Sorry, at the moment this is not possible with the cli. The only thing you could do at the moment is a ugly workaround. You could install the scm-script-plugin and execute the following groovy script with curl or something similar:

import javax.servlet.http.HttpServletRequest;
import de.triology.scm.plugins.groupmanager.GroupManagerResource;

def request = injector.getInstance(HttpServletRequest.class);
String groupName = request.getParameter("group");
String managerName = request.getParameter("manager");

if ( groupName == null || managerName == null ){
  throw new IllegalArgumentException( "parameter group and manager are required" );
};

def groupManager = injector.getInstance(GroupManagerResource.class);
def group = null;
for (def g : groupManager.getAll().getEntity().getEntity()){
  if (groupName.equals(g.getName())){
    group = g;
    break;
  };
};

if (group == null){
  throw new IllegalArgumentException( "group not found" );
};

if (!group.addManager(managerName)){
  throw new IllegalStateException("could not add manager to group");
};

if (groupManager.update(null, groupName, group).getStatus() != 204){
  throw new IllegalStateException("group update failed");
}

Here is an example with curl:

curl --user scmadmin:scmadmin --data @addmanager.groovy -XPOST -H "Content-Type:application/x-groovy" "http://localhost:8080/scm/api/rest/plugins/script?group=groupname&manager=managername"


Sebastian


--
You received this message because you are subscribed to the Google Groups "scmmanager" group.
To unsubscribe from this group and stop receiving emails from it, send an email to scmmanager+...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Gildas Cuisinier

unread,
May 13, 2014, 12:39:25 AM5/13/14
to scmma...@googlegroups.com
Thanks for your advice.
I'll try this today.

Do you plan to add possibility to extends the Rest and CLI in the futur ? :)

Sebastian Sdorra

unread,
May 19, 2014, 7:06:59 AM5/19/14
to scmma...@googlegroups.com
We will try to support such a feature with version 2.x of scm-manager.

Sebastian
Reply all
Reply to author
Forward
0 new messages