How to create repository and build permission targets in Artifactory

Pradnya Shinde
2019-05-21 01:52

Summary

How to create repository and build permission targets in Artifactory

Details

This is an example with sample command for creating repository and build permission targets in Artifactory.

Overall REST API documentation is covered here.

Resolution

Note: Replace the password. In this example admin user is used.

  • curl -uadmin:<password> -XPUT "http://localhost:8081/artifactory/api/v2/security/permissions/java-developers" -H "Content-type: application/json" -T build-info-permission.json
  • build-info-permission.json has the following wherein java-developers is the name of the permission target that will be created, generic-local is the name of a local repository of type Generic and testmaven is the name of a build existing in Artifactory:

{

  "name": "java-developers",

  "repo": {

     – "include-patterns": ["**"] (default),

     – "exclude-patterns": [""] (default),

     + "repositories": ["generic-local"],

     – "actions": {

          "users" : {

            "test1": ["read","write","manage"],

            "test2" : ["write","annotate", "read"]

          },

          "groups" : {

            "group1" : ["manage","read","annotate"],

            "readers" : ["read"]

          }

    }

  },

"build": {

     – "include-patterns": ["testmaven/**"] (default),

     – "exclude-patterns": [""] (default),

     + "repositories": ["artifactory-build-info"] (default, can't be changed),

     – "actions": {

          "users" : {

            "test1": ["read","manage"],

            "test2" : ["write"]

          },

          "groups" : {

            "group1" : ["manage","read","write","annotate","delete"],

            "readers" : ["read"]

          }

    }

  }

}