Search code examples
scmmanager

SCM-manager CLI to set branch write protection


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?


Solution

  • 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.