2

I have downloaded SCM-manager-CLI

I need to set the branch write protection for GIT repository in SCM-manager through CLI

I have set the same through web-app

I need to do that through CLI as a part of Automation

How to do that?

soundararajan.c
  • 2,538
  • 6
  • 29
  • 51

1 Answers1

0

Hi the cli has currently no support for properties, but you can use the rest api to set the properties:

curl -u scmadmin:scmadmin -v http://localhost:8080/scm/api/rest/repositories -XPOST -H 'Content-Type: application/json' -d '{
  "name": "newrepository",
  "description": "repository with branch protection",
  "type": "git",
  "properties": [
    { "key": "branchwp.enabled", "value": true },
    { "key": "branchwp.permissions", "value": "master,userone;develop,@devgroup;" }
  ],
  "permissions": [
    { "name": "userone", "type": "WRITE", "groupPermission": false },
    { "name": "devgroup", "type": "WRITE", "groupPermission": true }
  ]
}'

The example above creates a new repository with enabled branch protection.

sdorra
  • 2,382
  • 18
  • 16
  • same way how to give permission to the repository via rest api ? – soundararajan.c Dec 11 '17 at 10:16
  • Also , how to revoke the permission ( branch write protection , and normal permission ) granted to the user – soundararajan.c Dec 11 '17 at 10:36
  • @soundararajan.c i've updated the example to include permissions. If you like to update repository settings, you have to issue a PUT request to the repository url `curl -XPUT http://.../repositories/abc123 ...` (abc123 should be replaced with the id of the repository). For more informations about the rest api, have a look at https://docs.scm-manager.org/restdocs/current/ – sdorra Dec 11 '17 at 12:51