How do I create a repository with replication with REST queries?

JFrog Support
2016-10-06 13:35

When creating a new repository in Artifactory from the UI, you have to manually configure the replication settings.

If it’s a local repository, you have to specify the URL of the Artifactory repository you wish to push content to, and if it’s a remote repository proxying another Artifactory instance, you have to set the cron expression to set the frequency of the replication.

If you want to automate this process, you can do that with 2 REST queries:

    • Run the Create or Replace Repository Configuration in order to create the repository; This query consumes a json object that contains the repository configuration, a json to create a local repository should look like:

    • {

      "key" : "libs-release-local",

      "description" : "Local repository for in-house libraries",

      "notes" : "",

      "includesPattern" : "**/*",

      "excludesPattern" : "",

      "repoLayoutRef" : "maven-2-default",

      "enableNuGetSupport" : false,

      "enableGemsSupport" : false,

      "enableNpmSupport" : false,

      "enableDebianSupport" : false,

      "debianTrivialLayout" : false,

      "enablePypiSupport" : false,

      "enableDockerSupport" : false,

      "checksumPolicyType" : "client-checksums",

      "handleReleases" : true,

      "handleSnapshots" : false,

      "maxUniqueSnapshots" : 0,

      "snapshotVersionBehavior" : "unique",

      "suppressPomConsistencyChecks" : false,

      "blackedOut" : false,

      "propertySets" : [ "GTID", "artifactory" ],

      "archiveBrowsingEnabled" : false,

      "calculateYumMetadata" : false,

      "yumRootDepth" : 0,

      "rclass" : "local"


      1. Run the Set Repository Replication Configuration in order to configure the replication; This query consumes a json object to configure the replication, a json to enable replication on a local repository should look like:


      "url" : "{destination URL}",

      "socketTimeoutMillis" : 15000,

      "username" : "{destination URL username (if needed)}",

      "password" : "{destination URL password(if needed)}",

      "enableEventReplication" : false,

      "enabled" : false,

      "cronExp" : "0 0 /4 * * ?",

      "syncDeletes" : false,

      "syncProperties" : true,

      "repoKey" : "libs-release-local"


      These json examples are for creation of a local repository and it’s replication to a remote repository in another Artifactory instance, if you wish to get the format of such a json for creating a remote repository and it’s replication json, you can use the ‘Repository Configuration’ and ‘Get Repository Replication Configuration’ REST queries on existing repositories.